assembler / attachinary

Attachments handler for Rails that uses Cloudinary for storage.
MIT License
294 stars 129 forks source link

Validate presence error message #144

Open kleinjm opened 7 years ago

kleinjm commented 7 years ago

I have the following in my model:

class Cv < ActiveRecord::Base
  has_attachment :attachment, accessible: false
  validates :attachment, presence: true

If I attempt a save via form submit with no attachment, I see "Attachment files" as my error message. When I pry on the page, I see

[2] pry(#<#<Class:0x007fed94403ad8>>)> @cv.errors
=> #<ActiveModel::Errors:0x007fed851a2348
 @base=
  #<Cv:0x007fed7fe1a770
   id: nil,
   ...>
 @messages={:attachment_files=>[""]}>

and @cv.errors.full_messages => ["Attachment files "]. When I'm in the console, however, I see c.errors.full_messages => ["Attachment can't be blank"].

I would like to override the error message and cannot seem to do so with locales or validates :attachment, presence: { message: 'Testing' }.