Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Dynamic attr_accessible for Active Record
Branch: master

accessible_attributes Travis-CI

Dynamic attr_accessible for Active Record, inspired by Ryan Bates Railscasts episode 237.


Add the following line to your Gemfile gem 'accessible_attributes'

Then run bundle install and you're good to go.


This gem sets attr_accessible to nil on ActiveRecord::Base, requiring you to use attr_accessible in all of your Active Record models to enable mass-assignment.

In your controllers, to mass-assign attributes that are not enabled by default, see the following example @model = @model.accessible = :my_attribute @model.attributes = params[:model]

You can also set accessible to :all to make all attributes available for mass-assignment @model = @model.accessible = :all @model.update_attributes(params[:model])

For more information, see the Railscasts episode or read it on Asciicasts

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.


Copyright (c) 2011 Steven Hancock and EZMedium. See MIT-LICENSE for details.

Something went wrong with that request. Please try again.