0

carrierwave is giving me this validation error:

Image You are not allowed to upload "pages" files, allowed types: jpg, jpeg, gif, png

any idea how to remove the "image" attribute bit from the beginning? it doesn't read very well.

pingu
  • 8,719
  • 12
  • 50
  • 84
  • I guess you tried that https://github.com/jnicklas/carrierwave#i18n ? – pjam Oct 30 '12 at 08:33
  • 1
    This is not a carrierwave problem, it's a rails problem, and a pretty old one: http://www.ruby-forum.com/topic/196109 and http://stackoverflow.com/questions/808547/fully-custom-validation-error-message-with-rails – Chris Salzberg Oct 30 '12 at 08:33
  • @shioyama - That sounds like the solution, but how to do it for carrierwave? – pingu Oct 30 '12 at 08:36

1 Answers1

2

I believe this should work:

class MyModel < ActiveRecord::Base

  ...

  HUMANIZED_COLUMNS = {:image => ""}

  def self.human_attribute_name(attribute)
    HUMANIZED_COLUMNS[attribute.to_sym] || super
  end

 ...

end

Documentation on human_attribute_name

Alternatively, in your locales file, add:

en:
  activerecord:
    attributes:
      my_model:
        image: ""

In both cases, replace MyModel/my_model by the name of the activerecord class that you are uploading images to.

Chris Salzberg
  • 27,099
  • 4
  • 75
  • 82