attr_encryptor icon indicating copy to clipboard operation
attr_encryptor copied to clipboard

Incompatible with `wrap_parameters`

Open snikch opened this issue 11 years ago • 0 comments

When using wrap_parameters in Rails controllers[1], encrypted attributes are not passed through to the params hash for the controller resource.

wrap_parameters uses Model.attribute_names to determine which parameters should be allowed. This falls back to Model.column_names in ActiveRecord[2], which doesn't include the parameters defined by attr_encryptor.

I'm not sure where the best place to put this fix would be, since it appears to be AR specific.

To fix in my application, I did this in my model

  attr_encryptor :delivery_password
  attribute_names.push 'delivery_password'

[1] http://guides.rubyonrails.org/action_controller_overview.html#json-parameters [2] http://apidock.com/rails/ActiveRecord/AttributeMethods/ClassMethods/attribute_names

snikch avatar Sep 11 '13 00:09 snikch