diff options
author | Bogdan Gusiev <agresso@gmail.com> | 2011-12-23 10:05:39 +0200 |
---|---|---|
committer | Bogdan Gusiev <agresso@gmail.com> | 2011-12-23 10:05:39 +0200 |
commit | 150217f54f625b612f9b03f69f13d09b339d1822 (patch) | |
tree | 88576612805ce8b48f18c585216e5317f18e62f5 /activemodel/lib | |
parent | 17da02425e9eae597f11cf1b409cbbb78002875e (diff) | |
download | rails-150217f54f625b612f9b03f69f13d09b339d1822.tar.gz rails-150217f54f625b612f9b03f69f13d09b339d1822.tar.bz2 rails-150217f54f625b612f9b03f69f13d09b339d1822.zip |
AM::MAS.attr_protected: rework usage example.
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/mass_assignment_security.rb | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/activemodel/lib/active_model/mass_assignment_security.rb b/activemodel/lib/active_model/mass_assignment_security.rb index b2a54902a6..c895968f77 100644 --- a/activemodel/lib/active_model/mass_assignment_security.rb +++ b/activemodel/lib/active_model/mass_assignment_security.rb @@ -71,11 +71,11 @@ module ActiveModel # class Customer # include ActiveModel::MassAssignmentSecurity # - # attr_accessor :name, :password, :logins_count + # attr_accessor :name, :email, :logins_count # # attr_protected :logins_count - # # Suppose that admin can not change password for employee - # attr_protected :password, :as => :admin + # # Suppose that admin can not change email for customer + # attr_protected :logins_count, :email, :as => :admin # # def assign_attributes(values, options = {}) # sanitize_for_mass_assignment(values, options[:as]).each do |k, v| @@ -87,21 +87,21 @@ module ActiveModel # When using the :default role : # # customer = Customer.new - # customer.assign_attributes({ "name" => "David", "password" => "firstpass", :logins_count => 5 }, :as => :default) + # customer.assign_attributes({ "name" => "David", "email" => "a@b.com", :logins_count => 5 }, :as => :default) # customer.name # => "David" - # customer.password # => "firstpass" + # customer.email # => "a@b.com" # customer.logins_count # => nil # # And using the :admin role : # # customer = Customer.new - # customer.assign_attributes({ "name" => "David", "password" => "firstpass", :logins_count => 5}, :as => :admin) + # customer.assign_attributes({ "name" => "David", "email" => "a@b.com", :logins_count => 5}, :as => :admin) # customer.name # => "David" - # customer.password # => nil + # customer.email # => nil # customer.logins_count # => nil # - # customer.password = "alternative" - # customer.password # => "alternative" + # customer.email = "c@d.com" + # customer.email # => "c@d.com" # # To start from an all-closed default and enable attributes as needed, # have a look at +attr_accessible+. |