Rails 4 - strong parameters concept involvement in spree-2.1

后端 未结 2 604
谎友^
谎友^ 2021-02-09 15:27

How to add new fields for spree::user in Spree-2.1 + Rails4 ?

Like my old customization: ==========================

Spree::User.class_eval do

a         


        
2条回答
  •  旧巷少年郎
    2021-02-09 16:31

    @gmacdougall is right, however I want to note that if you're doing this in an extension, you may want to do this via a decorator. Your extension would have to define this in an initializer that is installed by the user via a generator, which cannot be maintained.

    # lib/spree/permitted_attributes_decorator.rb
    Spree::PermittedAttributes.class_eval do
      @@user_attributes.push(:f_name, :l_name)
    end
    

    You can add new attributes for many models in the Spree:PermittedAttributes module. Spree controllers obtain these attributes via the methods included by the Spree::Core::ControllerHelpers::StrongParameters module.

提交回复
热议问题