{"issue":{"milestone":{"title":"2.1","created_at":"2011-04-10T04:49:11Z","creator":{"id":5240,"login":"justinfrench","url":"https://api.github.com/users/justinfrench","avatar_url":"https://secure.gravatar.com/avatar/d21eafb0998a549a5821d130e03a0608?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"d21eafb0998a549a5821d130e03a0608"},"open_issues":15,"state":"open","due_on":"2012-01-15T08:00:00Z","closed_issues":29,"description":"","number":8,"url":"https://api.github.com/repos/justinfrench/formtastic/milestones/8"},"user":{"id":1402,"login":"trevrosen","url":"https://api.github.com/users/trevrosen","avatar_url":"https://secure.gravatar.com/avatar/49cf338627b02a0425264095d19056c5?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"49cf338627b02a0425264095d19056c5"},"title":"semantic_errors doesn't return errors on base object","created_at":"2011-12-16T19:42:37Z","labels":[{"name":"bug","url":"https://api.github.com/repos/justinfrench/formtastic/labels/bug","color":"e10c02"}],"updated_at":"2011-12-18T21:08:20Z","state":"open","id":2583516,"html_url":"https://github.com/justinfrench/formtastic/issues/759","closed_at":null,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"body":"Hard to believe, but seems to be true.  I've fixed the issue in a fork, and would appreciate any feedback I can get.  I've been looking for a flaw in my repro process or my understanding of the code because it makes no sense to me this core functionality would be broken in such a widely used library.  If this is a reasonable fix, I'll spec it up and create a proper pull request.\r\n\r\nhttps://github.com/trevrosen/formtastic/commit/2fddba5c6137a35426764be843a14ec3fe6a5c9b\r\n\r\nThe issue seems to be that you're referencing the old errors API.  As far as I can tell, the following always returns nil in the semantic_errors method body:\r\n\r\n```ruby\r\n@object.errors[:base]\r\n```\r\n\r\n__Repro:__\r\n\r\n* Create new Rails app with Rails 3.1.3 and \"gem 'formtastic'\" in the Gemfile\r\n* Add scaffolding/schema for User model, including string attribute __name__\r\n* add \"validates_presence_of :name\" to models/user.rb\r\n* Replace _form.html.erb code w/ Formtastic code\r\n* Include a call to semantic_errors at the top of form block\r\n* Attempt to create the user with a blank name\r\n\r\nInline errors will show, unordered list of errors will not.  Using the debugger, you can see that \r\n\r\n```ruby\r\n@object.errors[:base]  #=> nil\r\n@object.errors.keys    #=> [:name]\r\n```\r\n","number":759,"url":"https://api.github.com/repos/justinfrench/formtastic/issues/759","comments":5,"assignee":null},"comment":{"user":{"id":5240,"login":"justinfrench","url":"https://api.github.com/users/justinfrench","avatar_url":"https://secure.gravatar.com/avatar/d21eafb0998a549a5821d130e03a0608?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"d21eafb0998a549a5821d130e03a0608"},"created_at":"2011-12-18T21:08:20Z","updated_at":"2011-12-18T21:08:20Z","id":3196942,"body":"@trevrosen I've re-read your patch, and I'm confused.\r\n\r\n* `@object.errors[:base]` is a list of errors that were specifically added to the base object (rather than any specific attribute on the object)\r\n* The Railsguides still make mention of `errors[:base]`\r\n* `errors[:base]` still works in a Rails 3.1 app of mine\r\n* I can't see any \"newer\" way to access the errors on the base object than this in the documentation\r\n\r\nBy way of example:\r\n\r\n```\r\nclass User < ActiveRecord::Base\r\n  before_validation :add_bogus_error_to_base\r\n  def add_bogus_error_to_base\r\n    errors[:base] << \"bogus!\"\r\n  end\r\nend\r\n```\r\n\r\n```\r\n$ be rails console\r\nruby-1.8.7-p249 :007 > u = User.new; u.valid?; u.errors[:base]\r\n=> [\"Bogus!\"]\r\n```\r\n\r\nSo, I'm wondering if you're confused about what semantic_errors does?\r\n\r\nThe [documentation](https://github.com/justinfrench/formtastic/blob/master/lib/formtastic/helpers/errors_helper.rb#L10-40) says \"Generates an unordered list of error messages on the base object and optionally for a given set of named attribute.\", and I still think this is what the code does.\r\n\r\nDo you think differently?\r\n\r\nThe idea behind this helper was to provide a way for form authors to include any errors that were not specific to any particular object attribute (e.g. errors on the base) or any errors on object attributes for which there were no specific form inputs available (Paperclip is one plugin that tends to do this).\r\n\r\nIt's not designed as a way to render all errors at the top of the screen, Rails already has a helper for this.\r\n\r\nIf my understanding of what semantic_errors does is wrong, I'm very keep to fix the code, if you want to change it, let's talk more about your use case.","url":"https://api.github.com/repos/justinfrench/formtastic/issues/comments/3196942"},"action":"created"}