spree/spree — pull request #3566 by jhawthorn (2013-08-15 01:04:47+00:00)
Title: Spree::PermittedAttributes for more extensibility

With existing `ControllerHelpers::PermittedAttributes`, adding additional permitted attributes can only be done by overriding the method. To be done safely in extensions, this would rely on a lot of method aliasing.

This introduces `Spree::PermittedAttributes`, which has as module attributes for the the accessible attributes on the spree models. This is easily modifiable by spree applications or extensions.

Spree::PermittedAttributes.line_item_attributes << :my_custom_attribute

`ControllerHelpers::StrongParameters` contains the same methods as before but mostly delegates to `Spree::PermittedAttributes`. The controller helpers also describe the allowed nested attributes.

For more complex customization (ex. permissions depending on role), controllers can still override permitted_attributes` with `SimpleDelegator` (or similar) or override `permitted_*_attributes` methods themselves to modify the attributes on a per request basis.

Thanks to Hates, Radar, huoxito, and jstrong in #spree for quick discussion.