2015-04-14 13 views
1

我想在spree_order表中添加自定義字段。如何在Spree電子商務中的管理端spree_order中添加自定義字段?

我使用的是spree-3.0 stable和rails 4.2.0。

字段名稱是pre_order_id。

使用強參數。

現在它在控制檯中給出錯誤未經允許的參數:pre_order_id

我還附加pre_order_id使用以下步驟。

這個代碼寫在spree.rb

Spree::PermittedAttributes.class_eval do 

class_variable_set(:@@checkout_attributes,class_variable_get(:@@checkout_attributes).push(:pre_order_id)) 

end 

但問題仍然剩餘。

在此先感謝。

回答

0

我能夠加入到我的施普雷初始化的底部(初始化/ spree.rb)來實現:

Spree::PermittedAttributes.checkout_attributes << [:pre_order_id] 

作品在我的機器上。試一試。

1

要允許自定義字段順序表,你應該插入內

應用程序代碼/模型/大禮包/ order_decorator.rb

Spree::PermittedAttributes.order_attributes.push << :pre_order_id 

我使用相同的代碼在用戶模式,允許參數。

相關問題