gpt4 book ai didi

ruby-on-rails - spree 2.1强参数

转载 作者:行者123 更新时间:2023-12-04 06:09:52 24 4
gpt4 key购买 nike

有没有一种简单的方法可以在不改变默认值的情况下向 Spree 中的 Controller 添加新的允许参数?

我正在尝试更改 OrdersController 中的 orders_params 方法。

最佳答案

你不需要覆盖任何东西,你必须在你的 spree 初始化器中做到这一点

向产品 Controller 添加强参数...

Spree::PermittedAttributes.product_attributes << :new_attribute

等等..

检查此文件: https://github.com/spree/spree/blob/master/core/lib/spree/permitted_attributes.rb?source=c

或这篇博文: http://blog.crowdint.com/2014/06/24/how-to-add-custom-attributes-in-spree.html

关于ruby-on-rails - spree 2.1强参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21319828/

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