Class: Dorsale::CommentsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Dorsale::CommentsController
- Defined in:
- app/controllers/dorsale/comments_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/controllers/dorsale/comments_controller.rb', line 3 def create @comment = Comment.new(comment_params) @comment. = try(:current_user) :create, @comment if @comment.save flash[:success] = t("messages.comments.create_ok") else flash[:danger] = t("messages.comments.create_error") end redirect_to_back_url end |
#destroy ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/dorsale/comments_controller.rb', line 40 def destroy @comment = ::Dorsale::Comment.find params[:id] :delete, @comment if @comment.destroy flash[:notice] = t("messages.comments.delete_ok") else flash[:alert] = t("messages.comments.delete_error") end redirect_to_back_url end |
#edit ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/controllers/dorsale/comments_controller.rb', line 18 def edit @comment = ::Dorsale::Comment.find params[:id] :update, @comment render layout: false end |
#update ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/dorsale/comments_controller.rb', line 26 def update @comment = ::Dorsale::Comment.find params[:id] :update, @comment if @comment.update_attributes(comment_params) flash[:notice] = t("messages.comments.update_ok") else flash[:alert] = t("messages.comments.update_error") end redirect_to_back_url end |