THanks Richard, Could you post any further usage example as I am quite new in Ruby and Rails and do not understand what happening below in your code. Is :msg an attribute in the model? thanks, bogumbiker
On Sep 26, 11:20 pm, richardun <richar...@gmail.com> wrote: > Actually, bgumbiker, I just posted this answer yesterday so a bit more > searching might have produced an > answer.http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/... > > If you used Ranjan's answer, you'll have to enter a specific custom > message for each validation you do. If you use the solution I > outlined in that URL or below, you change the "humanization" version > of that column name so you can do validations as normal and when the > human name is used to display an error message, it'll use the one you > mapped. > > class Post < ActiveRecord::Base > > HUMANIZED_COLUMNS = {:msg => "Message"} > > def self.human_attribute_name(attribute) > HUMANIZED_COLUMNS[attribute.to_sym] || super > end > end > > Richard > > On Sep 26, 5:50 am, ranjan kumar <ranjankumar...@gmail.com> wrote: > > > Try this > > > class User < ActiveRecord::Base > > validate do |user| > > user.errors.add_to_base("This is my custom message") if user. > > attribute_name.blank? > > end > > end > > > On Sat, Sep 26, 2009 at 2:52 PM, bgumbiker <bogumil.bial...@gmail.com>wrote: > > > > Hello, > > > Any idea how to remove attribute name from validation error messages? > > > thanks, > > > bogumbiker --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---