Sha256: 054218067fd4cdcf9d22034fccc3f15cb4c7d4c1051bd8d61f6dc6f3389d5623

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

module Recruiter
  module Users
    class ArticlesController < UserController
      before_action :set_article, only: [:show, :edit, :update, :destroy]

      def index
        @articles = scope.page(page).per(per_page)
        respond_with(@articles)
      end

      def show
        respond_with(@article)
      end

      def new
        @article = scope.build
        respond_with(@article)
      end

      def create
        @article = scope.build(article_params)
        crud_flash @article.save
        respond_with(@article)
      end

      def edit
        respond_with(@article)
      end

      def update
        crud_flash @article.update(article_params)
        respond_with(@article)
      end

      def destroy
        crud_flash @article.destroy
        respond_with(@article)
      end

      private

      def scope
        current_user.articles
      end

      def set_article
        @article = scope.find(params[:id])
      end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
recruiter-0.1.2 app/controllers/recruiter/users/articles_controller.rb
recruiter-0.1.1 app/controllers/recruiter/users/articles_controller.rb
recruiter-0.1.0 app/controllers/recruiter/users/articles_controller.rb