pingu
pingu

Reputation: 8827

Customise carrierwave validation messages

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.

Upvotes: 0

Views: 624

Answers (1)

Chris Salzberg
Chris Salzberg

Reputation: 27374

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.

Upvotes: 2

Related Questions