gpt4 book ai didi

ruby - Spree 3.0 添加到扩展中允许的属性

转载 作者:数据小太阳 更新时间:2023-10-29 06:54:37 25 4
gpt4 key购买 nike

所以我正在做一个 spree 扩展,其中我有我自己的属性,我添加到 Spree::Shipment 并在结帐过程中添加了一个输入,问题是我的属性不是部分装运的允许属性,目前尚不清楚如何将其添加到允许属性中。我在 this pull req 上找到了对话上面说要使用

Spree::PermittedAttributes.shipment_attributes << :my_custom_attribute

但是,不清楚我应该把它放在哪里!?

“哦,把它放在spree.rb

这没有帮助。我试过把这段代码放在

lib/spree.rb
lib/spree/permitted_attributes.rb
lib/spree_decorator.rb
lib/spree/permitted_attributes_decorator.rb

( as suggested here ) 所有这些都会导致错误提示 shipment_attributes 没有被定义(所以大概代码在主文件定义 PermittedAttributes 之前运行被评估)或者根本没有任何反应。我应该将此代码放在哪里以将我的属性添加到允许的属性列表中?


编辑:由于人们似乎不清楚这一点,我已经尝试了我发布的链接中列出的所有内容。告诉我尝试其中的东西真是令人气愤。停止这样做。

最佳答案

“spree.rb”实际上是指config/initializers/spree.rb。这是 spree 配置的正确位置。我注意到你/那篇文章提到了各种文件,但没有提到这个文件。

一旦在这个文件中:

Spree::PermittedAttributes.shipment_attributes << :my_custom_attribute

正如你提到的或

Spree::PermittedAttributes.shipment_attributes.push :my_custom_attribute

如果这不起作用,您将需要提供更多详细信息。

关于ruby - Spree 3.0 添加到扩展中允许的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33769193/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com