diff options
author | José Valim <jose.valim@gmail.com> | 2012-05-04 12:44:34 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2012-05-04 12:44:34 -0700 |
commit | efb054baa0e8e5a1ebebbfc307f69bf846ceee89 (patch) | |
tree | d0287cbf6f9441a2bf78ffc8f1bc55f60e88aa8f /actionpack/lib/action_controller/metal/params_wrapper.rb | |
parent | 5384bdb855f67621f055ae79a2655c03b767a5cc (diff) | |
parent | bfb25f9cae0a4021d86daf5c928d7e9a10bd30e3 (diff) | |
download | rails-efb054baa0e8e5a1ebebbfc307f69bf846ceee89.tar.gz rails-efb054baa0e8e5a1ebebbfc307f69bf846ceee89.tar.bz2 rails-efb054baa0e8e5a1ebebbfc307f69bf846ceee89.zip |
Merge pull request #4445 from nragaz/role_based_params_wrapping
specify a role for identifying accessible attributes when wrapping params
Diffstat (limited to 'actionpack/lib/action_controller/metal/params_wrapper.rb')
-rw-r--r-- | actionpack/lib/action_controller/metal/params_wrapper.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/metal/params_wrapper.rb b/actionpack/lib/action_controller/metal/params_wrapper.rb index 5c28a8074f..1ab436a205 100644 --- a/actionpack/lib/action_controller/metal/params_wrapper.rb +++ b/actionpack/lib/action_controller/metal/params_wrapper.rb @@ -167,8 +167,9 @@ module ActionController unless options[:include] || options[:exclude] model ||= _default_wrap_model - if model.respond_to?(:accessible_attributes) && model.accessible_attributes.present? - options[:include] = model.accessible_attributes.to_a + role = options.has_key?(:as) ? options[:as] : :default + if model.respond_to?(:accessible_attributes) && model.accessible_attributes(role).present? + options[:include] = model.accessible_attributes(role).to_a elsif model.respond_to?(:attribute_names) && model.attribute_names.present? options[:include] = model.attribute_names end |