Sha256: d6dc777d8e439408470a2e6c9a08c1431a569714dc82a5870689266ae874072c

Contents?: true

Size: 1.72 KB

Versions: 1

Compression:

Stored size: 1.72 KB

Contents

require_dependency "rails_page_comment/application_controller"

module RailsPageComment
  class PageCommentsController < ApplicationController
    before_action :set_page_comment, only: [:show, :edit, :update, :destroy]

    # GET /page_comments
    def index
      @page_comments = PageComment.all
    end

    # GET /page_comments/1
    def show
    end

    # GET /page_comments/new
    def new
      @page_comment = PageComment.new
    end

    # GET /page_comments/1/edit
    def edit
    end

    # POST /page_comments
    def create
      @page_comment = PageComment.new(create_page_comment_params)
      if @page_comment.save
        render :edit
      else
        render :nothing  => true
      end
    end

    # PATCH/PUT /page_comments/1
    def update
      @page_comment.attributes = update_page_comment_params
      if @page_comment.valid?
        if @page_comment.changed?
          RailsPageComment.notify_changes_method_name.each do |m|
            self.class.notify_changes_class.send(m, @page_comment).deliver
          end
        end
        @page_comment.save
        render :edit
      else
        render :edit
      end
    end


    private
      # Use callbacks to share common setup or constraints between actions.
      def set_page_comment
        @page_comment = PageComment.find(params[:id])
      end

      # Only allow a trusted parameter "white list" through.
      def create_page_comment_params
        params.require(:page_comment).permit(:content, :page_uri)
      end

      # Only allow a trusted parameter "white list" through.
      def update_page_comment_params
        params.require(:page_comment).permit(:content, :page_uri)
      end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_page_comment-0.1.0 app/controllers/rails_page_comment/page_comments_controller.rb