Sha256: 6e19a342816abc39a662484ddd1b157fc5d48c93d38d67c6ec6c452ccd4e5c26

Contents?: true

Size: 999 Bytes

Versions: 15

Compression:

Stored size: 999 Bytes

Contents

class ArticlesController < ApplicationController
  load_and_authorize only: [:edit]
  require_login only: [:update]

  def index
    authorize_and_load_records!
  end

  def show
    load_and_authorize!
  end

  def new
    authorize!
    @article = Article.new
  end

  def edit
  end

  def create
    require_login!
    @article = Article.new(article_params)
    @article.user = current_user
    if @article.save
      redirect_to @article, notice: 'Article was successfully created.'
    else
      render :new
    end
  end

  def update
    @article = Article.find(params[:id])
    if @article.update(article_params)
      redirect_to @article, notice: 'Article was successfully updated.'
    else
      render :edit
    end
  end

  def destroy
    @article = Article.find(params[:id])
    @article.destroy
    redirect_to articles_url, notice: 'Article was successfully destroyed.'
  end

  private

    def article_params
      params.require(:article).permit(:title, :content)
    end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
adeia-0.10.0 spec/test_app/app/controllers/articles_controller.rb
adeia-0.9.2 spec/test_app/app/controllers/articles_controller.rb
adeia-0.9.1 spec/test_app/app/controllers/articles_controller.rb
adeia-0.9.0 spec/test_app/app/controllers/articles_controller.rb
adeia-0.8.6 spec/test_app/app/controllers/articles_controller.rb
adeia-0.8.5 spec/test_app/app/controllers/articles_controller.rb
adeia-0.8.4 spec/test_app/app/controllers/articles_controller.rb
adeia-0.8.3 spec/test_app/app/controllers/articles_controller.rb
adeia-0.8.2 spec/test_app/app/controllers/articles_controller.rb
adeia-0.8.1 spec/test_app/app/controllers/articles_controller.rb
adeia-0.8.0 spec/test_app/app/controllers/articles_controller.rb
adeia-0.7.1 spec/test_app/app/controllers/articles_controller.rb
adeia-0.7.0 spec/test_app/app/controllers/articles_controller.rb
adeia-0.6.2 spec/test_app/app/controllers/articles_controller.rb
adeia-0.6.1 spec/test_app/app/controllers/articles_controller.rb