Neil Bye wrote in post #1018907: > I have an app which I have upgraded to rails3. It is working fine but > for displaying error messages. > > Take i.e. new.html.erb. In the model I have several validations that > work, they do not create a user if the entries are wrong. On submission > it dutifully returns to new.html.erb but WITHOUT the nice red error > messages. > > I have been using > > <% if @user.errors.any? %> > <div id="error_explanation"> > <h2><%= pluralize(@user.errors.count, "error") %> prohibited this > user from being saved:</h2> > > <ul> > <% @user.errors.full_messages.each do |msg| %> > <li><%= msg %></li> > <% end %> > </ul> > </div> > <% end %> > > but that doesn't help. >
1) Is that a partial? If so, are you actually including it in a view somewhere, e.g. <%= render '...../error_messages' %> 2) Is the partial named correctly, e.g.: '_error_messages.html.erb ? 3) I'm not quite sure what the directory rules are for rails, but is the partial in a directory that can be accessed by multiple controllers, e.g. app/views/shared/_error_messages.html.erb? > Of course, you would have to have I think the problem may be deeper. Do you > know > what files are used when displaying the errors? Where does the error > variable come from?. It's 'errors' not 'error', and @user is an ActiveRecord::Base object, so the errors() method must be defined in that class or one of that class's parent classes. > Could it be a js problem? Sure. If your js says to hide any html elememts with id="error_explanation", then none of the error messages will be visible. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.