Is there some way I can either override or mirror (by writing a new helper) errors_messages_for ? Basically, I''m happy with the functionality, but I''d prefer to change the language and the default class/id names to speed things up a little for me. So, first I tried adding the new method show_error_messages_for to application_helper.rb, but I get "undefined method `show_error_messages_for'' for #<ActionView::Base:0x16933b8>", which I guess doesn''t surprise me. So where SHOULD I add this method/helper? I''ve seen Johan Sørensen''s view based solution on the list: <% if @post.errors.count > 0 %> <h3>The following errors was found</h3> <ul> <% @post.errors.each do |attr_name, message| %> <li><%= message %></li> <% end %> </ul> <% end %> ... but I don''t like the idea of repeating this over and over in each form/view. I''m a 3-day-old Ruby virgin, so be gentle :) --- Justin French, Indent.com.au justin.french-zULN+VWqVOIpAS55Wn97og@public.gmane.org Web Application Development & Graphic Design
On 27/01/2005, at 8:23 AM, Justin French wrote:> So, first I tried adding the new method show_error_messages_for to > application_helper.rb, but I get "undefined method > `show_error_messages_for'' for #<ActionView::Base:0x16933b8>", which I > guess doesn''t surprise me.Appologies for the list noise. I had a type in my method name -- it''s working now, living in application_helper.rb --- Justin French, Indent.com.au justin.french-zULN+VWqVOIpAS55Wn97og@public.gmane.org Web Application Development & Graphic Design
Is there anything similar to the Struts idiom of an ExceptionHandler in Rails? Most documentation I have seen for error handling (non-validation errors) with Rails revloves around having Apache set up to handle it. It would be nice if a given Rails app could handle exceptions internally and redirect to an application specific error page. Plus the "handler" could also log information about these unexpected types of errors, send emails, etc. Not sure where such a handler would be configured, but it would be easy to alter the ActionController::Base#render* methods to rescue Exceptions and see if there was a "handler" configured to deal with a given Exception. Thoughts? On Thu, 27 Jan 2005 08:34:20 +1100, Justin French <justin.french-zULN+VWqVOIpAS55Wn97og@public.gmane.org> wrote:> On 27/01/2005, at 8:23 AM, Justin French wrote: > > > So, first I tried adding the new method show_error_messages_for to > > application_helper.rb, but I get "undefined method > > `show_error_messages_for'' for #<ActionView::Base:0x16933b8>", which I > > guess doesn''t surprise me. > > Appologies for the list noise. I had a type in my method name -- it''s > working now, living in application_helper.rb > > --- > Justin French, Indent.com.au > justin.french-zULN+VWqVOIpAS55Wn97og@public.gmane.org > Web Application Development & Graphic Design > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
I think your looking for is in ActionController::Rescue Steve Longdo wrote:> Is there anything similar to the Struts idiom of an ExceptionHandler > in Rails? Most documentation I have seen for error handling > (non-validation errors) with Rails revloves around having Apache set > up to handle it. > > It would be nice if a given Rails app could handle exceptions > internally and redirect to an application specific error page. Plus > the "handler" could also log information about these unexpected types > of errors, send emails, etc. Not sure where such a handler would be > configured, but it would be easy to alter the > ActionController::Base#render* methods to rescue Exceptions and see if > there was a "handler" configured to deal with a given Exception. > Thoughts? > > > On Thu, 27 Jan 2005 08:34:20 +1100, Justin French > <justin.french-zULN+VWqVOIpAS55Wn97og@public.gmane.org> wrote: > >>On 27/01/2005, at 8:23 AM, Justin French wrote: >> >> >>>So, first I tried adding the new method show_error_messages_for to >>>application_helper.rb, but I get "undefined method >>>`show_error_messages_for'' for #<ActionView::Base:0x16933b8>", which I >>>guess doesn''t surprise me. >> >>Appologies for the list noise. I had a type in my method name -- it''s >>working now, living in application_helper.rb >> >>--- >>Justin French, Indent.com.au >>justin.french-zULN+VWqVOIpAS55Wn97og@public.gmane.org >>Web Application Development & Graphic Design >> >>_______________________________________________ >>Rails mailing list >>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>http://lists.rubyonrails.org/mailman/listinfo/rails >> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails