hey all, nice that we can override the error message when a certain type of validation fails by using :message. i''ve used this to help the user so they can better understand why the app is rejecting their input (or lack of input).. problem: the damn message comes up, but it prepends the message with the fieldname .humanize''d !! I do not want that. anybody know how to make it do what i want (just the message)?? thanks in advance and happy railsing (railling?) to all! stuart (the other one) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I think, you can do this, but not with using validation helpers. I use
the following code (in model/ *.rb file), for example:
.....
protected
def validate
errors.add({}, "The price should be positive.") unless
self.price.nil? || self.price > 0.0
end
.....
---------
Sergey
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
I think, you can do this, but not with using validation helpers. I use
the following code (in model/ *.rb file), for example:
.....
protected
def validate
errors.add({}, "The price should be positive.") unless
self.price.nil? || self.price > 0.0
end
.....
---------
Sergey
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
write your own version of error_messages_for() . Just have a look at
the source of this Helper Method in the API,
it''s very simple ...
instead of
Object.errors.fullmessages
just use
Object.errors.each {|attr, msg| ...}
to loop though the errors and use only your defined messages without
the prepended Attribute name.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---