Skip to content

Instantly share code, notes, and snippets.

@rud
Created June 25, 2012 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rud/2988115 to your computer and use it in GitHub Desktop.
Save rud/2988115 to your computer and use it in GitHub Desktop.
Rails 3.2.6 config.active_record.whitelist_attributes adds blank attribute to .accessible_attributes

If you use tests of the form: User.accessible_attributes.should =~ [:email, :password] you'll get an extra attribute called "" if you set config.active_record.whitelist_attributes = true, and thus a specfailure. Annoying.

Instead, you can add this to your config/application.rb:

# Require attr_accessible to be used on all models for mass-assignment to work
ActiveRecord::Base.instance_eval do
  attr_accessible # none - and this method doesn't whitelist an attribute with the name ""
end
@rud
Copy link
Author

rud commented Jun 25, 2012

Fixed in commit:00ff0a6776aca4977dc6eab5ec130c67e36c36ac

@rud
Copy link
Author

rud commented Jun 25, 2012

rails/rails@00ff0a6 specifically

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment