Hi,
When an error is display, it first show the column concerned. Does
someone knows how to change the display column name?
Greg
Hi,
When an error is display, it first show the column concerned. Does
someone knows how to change the display column name?
Greg
Hi Greg,
Rails by default use DB column name while displaying errors on UI. You
can
choose one of the following options to write custom validation errors
–Haribhau
Put this in the model:
HUMAN_ATTRIBUTES = {:some_column => ‘Column display
name’, :some_other_column => ‘Another column display name’}
def self.human_attribute_name(attr)
HUMAN_ATTRIBUTES[attr.to_sym] || super
end
Obviously you want to replace my examples (:some_column, ‘Column
display name’, etc.) with your column names and display versions of
those names.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs