comment policy and test updates

This commit is contained in:
Mark Moser
2017-02-14 10:17:42 -06:00
parent 906b62247b
commit a8c42af3de
5 changed files with 64 additions and 19 deletions

View File

@ -15,12 +15,10 @@ module Admin
end
def create
authorize QuizComment
comment = QuizComment.create(
comment_params.merge(user_id: current_user.id, test_hash: params[:test_hash])
)
comment = QuizComment.new(comment_params.merge(user_id: current_user.id, test_hash: params[:test_hash]))
authorize comment
flash_message = if comment.persisted?
flash_message = if comment.save
{ success: "Sucessfully created comment" }
else
{ error: "Failed to save comment" }