Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Dynamic attr_accessible for Active Record

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 log
Octocat-spinner-32 spec
Octocat-spinner-32 tasks
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rspec
Octocat-spinner-32 Gemfile
Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 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.