aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-06-23 13:37:39 -0700
committerJosé Valim <jose.valim@gmail.com>2011-06-23 13:37:39 -0700
commit4389fc9733835186cf92a72e0dd419ac6caa023c (patch)
treeeff11fddee54d360522a6dc8034229b61cda41ff /activemodel/lib
parent87d6865bf71eb3feb5831ca541f3493aa36ee88e (diff)
parentee044ea5477b4af41d2c0cebb13e47600da7493a (diff)
downloadrails-4389fc9733835186cf92a72e0dd419ac6caa023c.tar.gz
rails-4389fc9733835186cf92a72e0dd419ac6caa023c.tar.bz2
rails-4389fc9733835186cf92a72e0dd419ac6caa023c.zip
Merge pull request #1829 from wildchild/master
Allow to specify roles for mass-assignment as array
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/mass_assignment_security.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/mass_assignment_security.rb b/activemodel/lib/active_model/mass_assignment_security.rb
index a7b4706906..c04de5b9a4 100644
--- a/activemodel/lib/active_model/mass_assignment_security.rb
+++ b/activemodel/lib/active_model/mass_assignment_security.rb
@@ -1,5 +1,6 @@
require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/string/inflections'
+require 'active_support/core_ext/array/wrap'
require 'active_model/mass_assignment_security/permission_set'
require 'active_model/mass_assignment_security/sanitizer'
@@ -111,7 +112,10 @@ module ActiveModel
role = options[:as] || :default
self._protected_attributes = protected_attributes_configs.dup
- self._protected_attributes[role] = self.protected_attributes(role) + args
+
+ Array.wrap(role).each do |name|
+ self._protected_attributes[name] = self.protected_attributes(name) + args
+ end
self._active_authorizer = self._protected_attributes
end
@@ -170,7 +174,10 @@ module ActiveModel
role = options[:as] || :default
self._accessible_attributes = accessible_attributes_configs.dup
- self._accessible_attributes[role] = self.accessible_attributes(role) + args
+
+ Array.wrap(role).each do |name|
+ self._accessible_attributes[name] = self.accessible_attributes(name) + args
+ end
self._active_authorizer = self._accessible_attributes
end