Dynamic attr_accessible for Active Record, inspired by Ryan Bates Railscasts episode 237.
Add the following line to your
bundle install and you're good to go.
This gem sets
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
:all to make all attributes available for mass-assignment
@model = Model.new
@model.accessible = :all
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.