7

Is there a easy way to add a new permitted parameter to controllers in Spree without altering the defaults ?

I'm trying to change the orders_params method in OrdersController.

2 Answers 2

12

You don't need to override anything, you have to do this in your spree initializer

To add a strong param to products controller...

Spree::PermittedAttributes.product_attributes << :new_attribute

and so on..

check this file: https://github.com/spree/spree/blob/master/core/lib/spree/permitted_attributes.rb?source=c

or this blog post: http://blog.crowdint.com/2014/06/24/how-to-add-custom-attributes-in-spree.html

1
  • Nice @Steven, that is even better. Thanks Mar 4, 2014 at 23:32
3

You'll probably want to override this function:

https://github.com/spree/spree/blob/v2.1.4/core/lib/spree/core/controller_helpers/strong_parameters.rb#L28-L32

to include the parameters you want. The Spree Logic Customization Guide should give you instructions on how to override that method in that class easily.

1
  • 1
    Yeah that was the droid I was looking for. Thanks. Jan 24, 2014 at 3:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.