27 lines
705 B
Ruby
27 lines
705 B
Ruby
# frozen_string_literal: true
|
|
module Admin
|
|
class CommentController < AdminController
|
|
before_action { authorize QuizComment }
|
|
|
|
def create
|
|
comment = QuizComment.create(
|
|
comment_params.merge(user_id: current_user.id, test_hash: params[:test_hash])
|
|
)
|
|
|
|
if comment.persisted?
|
|
redirect_to admin_result_path(params[:test_hash]),
|
|
flash: { success: "Sucessfully created comment" }
|
|
else
|
|
redirect_to admin_result_path(params[:test_hash]),
|
|
flash: { error: "Failed to save comment" }
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def comment_params
|
|
params.require(:quiz_comment).permit(:message, :id)
|
|
end
|
|
end
|
|
end
|