Hi Everyone, Is there a gem plugins that can customize the built-in error messages that we are seeing when there''s an error an ActiveRecord? I am referring on this message "7 errors prohibited this RECORD from being saved" -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Haven''t seen a plugin like that. Though you could rather easily create your own partial to do this by accessing the errors directly through ====================@record.errors ====================Personally, I have always favored designs that make use of the "error_message_on" helper -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ok.. After a few ''google'' session, I finally found this
solution and I
hope it will helps you out there.
Insert this block of code on your application_helper.rb (found on
app/helper)
-----------------
def error_messages_for(object_name, options = {})
options = options.symbolize_keys
object = instance_eval "@#{object_name}"
unless object.errors.empty?
content_tag("div",
content_tag(options[:header_tag] || "h2",
"WARNING:") +
content_tag("ul", object.errors.full_messages.collect { |msg|
content_tag("li", msg) }),
"id" => options[:id] || "errorExplanation",
"class" =>
options[:class] || "errorExplanation"
)
end
end #def error_messages_for
-----------------
Thats it.. !!! a customized error message header for your ActiveRecord
error message box. ;-)
--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---