Skip to content

Commit

Permalink
Fill in README
Browse files Browse the repository at this point in the history
  • Loading branch information
DefV committed Jun 2, 2009
1 parent 11931f6 commit 3a9cba3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
13 changes: 0 additions & 13 deletions README

This file was deleted.

21 changes: 21 additions & 0 deletions README.rdoc
@@ -0,0 +1,21 @@
== ContextAssignment

Protect your attributes from mass_assignment per context. Sometimes you want an admin to be able to edit a users is_admin boolean field, but never the user himself. This is in-context attribute setting.

== Example

class Person < ActiveRecord::Base
attr_accessible :name, :first_name # default context
attr_accessible :name, :first_name, :is_admin, :context => :backoffice
attr_accessible :api_last_used, :context => :api
end

In your different controllers, you can the do

Person.new(:name => 'De Poorter', :first_name => 'Jan') # default context

Person.find(params[:id]).update_attributes(params[:person], :context => :backoffice)

Person.find_by_api_key!(params[:api_key]).update_attributes(params[:person], :context => :api)

Copyright (c) 2009 Jan De Poorter, released under the MIT license

0 comments on commit 3a9cba3

Please sign in to comment.