First, you can have a basic validation via JS adding to that body input the 
attribute required: true. That will trigger HTML5 validation if you try tu 
submit a empty input.
If you have your validation via ActiveRecord in your model, you need tu put 
specific code in your view to show the error. Are you looking for 
@your_record.errors ?
You can see the error messages triggered by your validation (on the model) 
looking at @your_record.errors.full_messages

El miércoles, 26 de diciembre de 2018, 7:58:32 (UTC-3), jason cao escribió:
>
> Hi,
>
> How can I show error messages if a comment is invalid? E.g. when a comment 
> body is empty. I add validation in the model class, and the validation 
> itself works, but it won't show any error message. Can you please help? 
> Many thanks!
>
> Regards,
> Jason
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/66e477a6-d771-4544-b621-3cf8d91fb037%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to