Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate presence error message #144

Open
kleinjm opened this issue Feb 13, 2017 · 0 comments
Open

Validate presence error message #144

kleinjm opened this issue Feb 13, 2017 · 0 comments

Comments

@kleinjm
Copy link

kleinjm commented Feb 13, 2017

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' }.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant