Rails 3 - Active_admin 选择多对多中的嵌套对象
我有两个型号。优惠和商店。 我想在创建商店时添加已创建的优惠。 我想在创建交易时添加已创建的疮口。 我正在尝试使用 f.has_many,但无法使其工作。
我的关系是使用 has_and_belongs_to_many :deals 和 has_and_belongs_to_many :stores (在模型中)建立的。
我的商店自定义表单具有以下内容:
f.inputs "Deals" do
f.has_many :deals do |deal|
deal.input :id, :as => :select, :include_blank => false
end
end
我不知道如何向商店添加交易。
有什么帮助吗?
I have two models. Deals and Stores.
I want to add already created Deals when creating a Store.
I want to add already created Sores when creating a Deal.
I am trying to use f.has_many, but I can't make it working.
My relationship is built using has_and_belongs_to_many :deals and has_and_belongs_to_many :stores (in the models)
My store custom form has the following:
f.inputs "Deals" do
f.has_many :deals do |deal|
deal.input :id, :as => :select, :include_blank => false
end
end
I don't know how to add deals to the store.
Any help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是检查一下,但是您
的 Store 模型中是否有声明,并且
Deals 模型中是否有声明?
您可能需要检查以下两个页面:
http://apidock.com/rails/ActiveRecord/ NestedAttributes/ClassMethods/accepts_nested_attributes_for
https://github.com/justinfrench/formtastic (在页面中搜索accepts_nested_attributes_for)
Just checking, but do you have an
declaration in your Store model, and an
declaration in your Deals model?
You may want to check these two pages:
http://apidock.com/rails/ActiveRecord/NestedAttributes/ClassMethods/accepts_nested_attributes_for
https://github.com/justinfrench/formtastic (search in the page for accepts_nested_attributes_for)