1

On the screenshot, you'll see that invalid feedback is specifying the attribute name from the input, here "Adulthood". I don't want it and i can't delete it. It's not in the acceptance message from the model, not in the view. Where does it come from ?enter image description here

Code from the model :

  validates :adulthood, acceptance: { message: "Only adults can signup on La Voyageuse" }, on: :create

Code from the view :

<%= f.input :adulthood, as: :boolean, label: t('.adulthood?'), class:"form-checkbox" %>
Maxime Boué
  • 648
  • 7
  • 10
  • You can find you solution [Fully custom validation error message](https://stackoverflow.com/questions/808547/fully-custom-validation-error-message-with-rails) and this is another one similiar to your problem [Remove field name from error message](https://stackoverflow.com/questions/5375407/removing-field-name-from-validation-error-message) – Tanay Sharma Jan 07 '19 at 09:44
  • Possible duplicate of [removing field name from validation error message](https://stackoverflow.com/questions/5375407/removing-field-name-from-validation-error-message) – Tanay Sharma Jan 07 '19 at 09:48

2 Answers2

1

You have not inspected your view part which display error log correctly. Following will help you to inspect and handle your issue

u = User.new
u.valid?  # => false

u.errors.messages # => {:email=>["This field is required."], :password=>["This field is required."]}

u.errors.full_messages #  # => ["Email This field is required.", "Password This field is required."]

You was just subjected to show,

u.errors.messages[:email] # => "This field is required."

Inspect and edit your code in view.

ray
  • 5,454
  • 1
  • 18
  • 40
0

I added a custom error message on the input to fix the problem :

<%= f.input :adulthood, as: :boolean, label: t('.adulthood?'), class:"form-checkbox", error: "You need to be an adult" %>

It will be internationalized so i'll call the same i18n tag than the model.

Maxime Boué
  • 648
  • 7
  • 10