gpt4 book ai didi

ruby-on-rails - 如何允许 Spree API 的参数?

转载 作者:行者123 更新时间:2023-12-03 21:33:10 26 4
gpt4 key购买 nike

我如何允许 Spree API 请求的参数?

我在以下文件中添加了一个新参数:note:

spree_api/app/helpers/spree/api/api_helpers.rb

Spree::Api::ApiHelpers.module_eval do
@@order_attributes = [
:id, :number, :item_total, :total, :ship_total, :state, :adjustment_total,
:user_id, :created_at, :updated_at, :completed_at, :payment_total,
:shipment_state, :payment_state, :email, :special_instructions, :channel,
:included_tax_total, :additional_tax_total, :display_included_tax_total,
:display_additional_tax_total, :tax_total, :currency, :notes
]
end

但是,每次发送 :note 参数时,我都会在控制台中收到以下响应:

Unpermitted parameters: id, number, item_total, total, state, adjustment_total, user_id, completed_at, payment_total, shipment_state, payment_state, created_at, updated_at, currency, additional_tax_total, channel, included_tax_total, notes

将允许的参数添加到 Spree API 调用的正确方法是什么?

我正在使用以下 gem:

spree (2.4.3.beta)
spree_api (= 2.4.3.beta)

我的 Rails 版本是:Rails 4.1.8

最佳答案

对于 order_attributes,您将使用以下行

我相信你的 order_decorator.rb:

Spree::PermittedAttributes.order_attributes << :your_attribute

关于ruby-on-rails - 如何允许 Spree API 的参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29696145/

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