Fix adding blank comments to existing annotations
We were using the `present?` method, which will always return true for a comment object.
This commit is contained in:
@@ -39,8 +39,8 @@ class Legislation::AnnotationsController < Legislation::BaseController
|
||||
|
||||
@annotation = existing_annotation
|
||||
if @annotation.present?
|
||||
comment = @annotation.comments.create(body: annotation_params[:text], user: current_user)
|
||||
if comment.present?
|
||||
comment = @annotation.comments.build(body: annotation_params[:text], user: current_user)
|
||||
if comment.save
|
||||
render json: @annotation.to_json
|
||||
else
|
||||
render json: comment.errors.full_messages, status: :unprocessable_entity
|
||||
|
||||
Reference in New Issue
Block a user