2
我的应用程序有3种型号: 我使用与simple_form宝石嵌套形式顾问,项目与预约Rails的simple_form嵌套形式的联系
class Consultant < ActiveRecord::Base
has_many :appointments
end
class Project < ActiveRecord::Base
has_many :appointments, :dependent => :destroy
accepts_nested_attributes_for :appointments, :allow_destroy => true
end
class Appointment < ActiveRecord::Base
belongs_to :consultant
belongs_to :project
end
我的形式如下:
= simple_nested_form_for(@project) do |f|
%div.field
= f.input :name, :label => 'Nom du projet'
= f.simple_fields_for :appointments do |builder|
= render 'appointment_fields', :f => builder
= f.link_to_add "ajouter un consultant", :appointments
%div
%div.actions
= f.submit
与部分:
%p.fields
= f.input :consultant_id, :input_html => { :class => 'special' }
= f.association :consultant
= f.input :nb_days, :input_html => { :class => 'special',:size => 10 }
= f.input :rate, :input_html => {:size => 10}
= f.link_to_remove "Remove this task"
是否有可能做一些事情这与simple_form一样简单吗? 答案是肯定的:它很好地工作
什么是错误? – rafaelfranca
错误是:/Users/herveleroy/Dropbox/compta/app/views/projects/_appointment_fields.html.haml在哪里行#4提出: 协会:找不到顾问 – rvopale
协会:顾问找不到 – rvopale