Ruby on rails 如何提交两份带有一个按钮的表格3
我想用一个按钮提交两份表格 以下是我的代码:- 利率.rbRuby on rails 如何提交两份带有一个按钮的表格3,ruby-on-rails,ruby-on-rails-3.2,Ruby On Rails,Ruby On Rails 3.2,我想用一个按钮提交两份表格 以下是我的代码:- 利率.rb belongs_to :target, :polymorphic => true belongs_to :location has_many :rates has_many :rates, :as => :target 位置.rb belongs_to :target, :polymorphic => true belongs_to :location has_many :rates has_many :ra
belongs_to :target, :polymorphic => true
belongs_to :location
has_many :rates
has_many :rates, :as => :target
位置.rb
belongs_to :target, :polymorphic => true
belongs_to :location
has_many :rates
has_many :rates, :as => :target
event.rb
belongs_to :target, :polymorphic => true
belongs_to :location
has_many :rates
has_many :rates, :as => :target
form.html.haml
= form_for [@event, @rate] do |form|
%ul
%li= form.radio_button :rate, "Excellent"
%li Excellent
%li= form.radio_button :rate, "Okay"
%li Okay
%li= form.radio_button :rate, "Poorly organized"
%li Poorly organized
%li= form.radio_button :rate, "Didn't happen"
%li Didn't happen
=form_for [@event.location, @rate] do |form|
%ul
%li= form.radio_button :rate, "Excellent"
%li Excellent
%li= form.radio_button :rate, "Okay"
%li Okay
%li= form.radio_button :rate, "Nothing special"
%li Nothing special
如何做到这一点?我今天也遇到了同样的情况,我做到了: 在form.html.haml中添加一个链接:(我用ERB写的)
就这样 如果不通过AJAX提交至少一个表单,您就不能这样做。AJAX解决方案是什么?不清楚您为什么要这样做。看看insteadnested属性,如果我有一个模型引用两个模型,那么嵌套属性就会起作用,例如:-event有多个:rates,:locations,那么我可以使用字段,在我的例子中可以使用字段吗?