From 3a9cba31828ac4e13b0bb87c51621a26a1def13f Mon Sep 17 00:00:00 2001 From: Jan De Poorter Date: Tue, 2 Jun 2009 15:14:58 +0200 Subject: [PATCH] Fill in README --- README | 13 ------------- README.rdoc | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 13 deletions(-) delete mode 100644 README create mode 100644 README.rdoc diff --git a/README b/README deleted file mode 100644 index 7eabe13..0000000 --- a/README +++ /dev/null @@ -1,13 +0,0 @@ -ContextAssignment -================= - -Introduction goes here. - - -Example -======= - -Example goes here. - - -Copyright (c) 2009 [name of plugin creator], released under the MIT license diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 0000000..bb5956b --- /dev/null +++ b/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