Skip to content
Dynamic attr_accessible for Active Record
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
log
spec
tasks
.gitignore
.rspec
Gemfile
MIT-LICENSE
README.md
Rakefile
accessible_attributes.gemspec

README.md

accessible_attributes Travis-CI

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

Installation

Add the following line to your Gemfile gem 'accessible_attributes'

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

Usage

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.new @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.new @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

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

Something went wrong with that request. Please try again.