Sha256: 66ad0e5148541341c707be7c5a02bb525a0ea3b79bbf87d3100f672039eddac8

Contents?: true

Size: 752 Bytes

Versions: 13

Compression:

Stored size: 752 Bytes

Contents

# encoding: utf-8

module Dorsale
  class CommentsController < ApplicationController
    def create
      if defined?(current_user) && current_user.present?
        @comment = current_user.comments.new(comment_params)
      else
        @comment = Comment.new(comment_params)
      end
      
      if @comment.save
        flash[:success] = "Comment was successfully created."
      else
        flash[:danger] = "Error : comment not saved."
      end
      
      redirect_to params[:back_url] || request.referer || main_app.root_path
    end
    
    private
    
    def permitted_params
      [:commentable_id, :commentable_type, :text]
    end
    
    def comment_params
      params.require(:comment).permit(permitted_params)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
dorsale-1.2.6 app/controllers/dorsale/comments_controller.rb
dorsale-1.2.5 app/controllers/dorsale/comments_controller.rb
dorsale-1.2.4 app/controllers/dorsale/comments_controller.rb
dorsale-1.2.3 app/controllers/dorsale/comments_controller.rb
dorsale-1.2.2 app/controllers/dorsale/comments_controller.rb
dorsale-1.2.1 app/controllers/dorsale/comments_controller.rb
dorsale-1.2.0 app/controllers/dorsale/comments_controller.rb
dorsale-1.1.4 app/controllers/dorsale/comments_controller.rb
dorsale-1.1.3 app/controllers/dorsale/comments_controller.rb
dorsale-1.1.2 app/controllers/dorsale/comments_controller.rb
dorsale-1.1.1 app/controllers/dorsale/comments_controller.rb
dorsale-1.1.0 app/controllers/dorsale/comments_controller.rb
dorsale-1.0.4 app/controllers/dorsale/comments_controller.rb