docbrown/app/controllers/resource_admin/comments_controller.rb

21 lines
639 B
Ruby

module ResourceAdmin
class CommentsController < ResourceAdmin::ApplicationController
def update
comment = Comment.find(params[:id])
if comment.update(comment_params)
flash[:notice] = "Comment successfully updated"
redirect_to "/resource_admin/comments/#{comment.id}"
else
flash.now[:error] = comment.errors.full_messages
render :new, locals: { page: Administrate::Page::Form.new(dashboard, comment) }
end
end
private
def comment_params
accessible = %i[user_id body_markdown deleted score]
params.require(:comment).permit(accessible)
end
end
end