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" %>
2

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.