Jump to content

The ultimate community for Ruby on Rails developers.


Nicer display of validation errors in Rails 4?

validations rails4 error handling

  • Please log in to reply
2 replies to this topic

#1 Vell



  • Members
  • 100 posts
  • LocationWashington, DC

Posted 04 September 2013 - 12:35 PM

I noticed that validation errors in rails 4 display as if the applications had crashed or hit a critical error. In rails 3 or even 2 when a valiation was hit it would at least render the page again with the list of validation errors.


I have not figured out how to change this so that when the user hits a validation error in the new/edit form that that form is re displayed with a nice validation error showing what the issue is.


Is it possible to somehow trap on that to render the errors?

#2 Kelli Shaver

Kelli Shaver


  • Administrators
  • 76 posts
  • LocationKentucky

Posted 05 September 2013 - 03:30 AM

Hmmm, validation errors display the same way they always have. Double check your error message - it sounds like it's probably throwing a different application error. 


Here's an example


  def create
    @person = Person.new(model_params)
    if @person.save
      redirect_to @person
      render action: "new"

#3 Vell



  • Members
  • 100 posts
  • LocationWashington, DC

Posted 05 September 2013 - 01:49 PM

Hmm I think you might be right Kelli. If I can reproduce the application error I will post it. I was obsessing over this while I was sleeping and realized part of the issue is that I don't have anything that displays error messages when they come up. Because I used the template generator for from the bootstrap-rails gem, it didn't have any code for displaying errors.

Also tagged with one or more of these keywords: validations, rails4, error handling

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users