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

semantic_errors displays duplicates in Rails 3.1RC #576

Closed
ghost opened this issue May 26, 2011 · 1 comment
Closed

semantic_errors displays duplicates in Rails 3.1RC #576

ghost opened this issue May 26, 2011 · 1 comment

Comments

@ghost
Copy link

ghost commented May 26, 2011

errors.add :base, "An error message"

in the model and

form.semantic_errors :base

in the view yields

<ul class="errors"><li>Base An error message</li><li>An error message</li></ul>
@justinfrench
Copy link
Member

This is "by design" (the behaviour you're describing is as it's documented and tested to work). It's purpose is mainly to render errors on :base out of the box:

# Renders errors on :base
<%= f.semantic_errors %>

In addition, you can optionally pass in other attributes you want to also render errors for. The use case was (if I recall correctly) that Attachment Fu or Paperclip had file upload errors on other attributes that weren't represented by form inputs.

# Renders errors on :base *and* on :something special
<%= f.semantic_errors :something_special %>

So, you're example above is, not surprisingly, rendering the errors on :base twice.

This causes me to wonder:

  1. were you getting different results in Rails 3.0, or is this a fresh app?
  2. what were you expecting semantic_errors to do differently?

The only code change I can think of is to drop :base from the list if it's been passed in as an arg like the example above, removing the duplication. I'll work on that, please get back to me on the rest @tanman726.

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

No branches or pull requests

1 participant