Model
class Product
include Mongoid::Document
field :name, type: String
field :description, type: String
...
embeds_one :pricing
end
class Pricing
include Mongoid::Document
field :retail, type: Integer, default: 0
field :sale, type: Integer, default: 0
embedded_in :product
end
现在我要添加一条 Product,提交的数据包含 Pricing,这时候健壮参数要怎么写呢?
我是这么写的,可是不对 - -
params.require(:product).permit(
:slug, :sku, :name, :description,
:total_reviews, :average_review, :main_cat_id,
:pricing_sale, :pricing_review
)
已解决:
params.require(:product).permit(
:slug, :sku, :name, :description,
:total_reviews, :average_review, :main_cat_id,
pricing: [ :sale, :retail ]
)