* Allow changing user for comments in admin panel * Add successful flash msg * Use user_id instead of name for comment admin
21 lines
608 B
Ruby
21 lines
608 B
Ruby
module Admin
|
|
class CommentsController < Admin::ApplicationController
|
|
def update
|
|
comment = Comment.find(params[:id])
|
|
if comment.update(comment_params)
|
|
flash[:notice] = "Comment successfully updated"
|
|
redirect_to "/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]
|
|
params.require(:comment).permit(accessible)
|
|
end
|
|
end
|
|
end
|