ruby on rails - How to change error message of model in rails3 on attach file name -



ruby on rails - How to change error message of model in rails3 on attach file name -

i need alter error message

my model code is:

class resume < activerecord::base attr_accessible :key_skills, :resume_category, :about_myself, :year_experience, :month_experience, :current_salary, :education_details, :jobs_preference, :resume_title,:avatar,:avatar_file_name,:avatar_content_type has_attached_file :avatar, :storage => :dropbox, :dropbox_credentials => "#{rails.root}/config/dropbox.yml", :dropbox_options => { :unique_filename => true } validates_format_of :avatar_file_name, :with => %r{\.(docx|doc|pdf)$}i,:message => "accept doc , pdf"

but error message displaying on submit form : "avatar file name take doc , pdf"

i need error message: "accept doc , pdf"

you have alter :"errors.format" in locale file, format: %{message}. doing this, each message of model, message printed out.

optionally, can utilize this: @resume.errors[:avatar_file_name][0] 0 index because have validations (for now).

however, best solution problem maybe this:

<% @resume.errors.each |attr, msg| msg = @resume.errors.full_message(attr, msg) unless attr == :avatar_file_name %>

ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1 ruby-on-rails-3.2

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -