我有两个模型,开发人员和任务,
class Developer < ActiveRecord::Base
attr_accessible :address, :comment, :email, :name, :nit, :phone, :web
has_many :assignments
has_many :tasks, :through => :assignments
end
class Task < ActiveRecord::Base
attr_accessible :description, :name, :sprint_id, :developer_ids
has_many :assignments
has_many :developers, :through => :assignments
end
class Assignment < ActiveRecord::Base
attr_accessible :accomplished_time, :developer_id, :estimated_time, :status, :task_id
belongs_to :task
belongs_to :developer
end
我通过添加分配表来处理关系,因此我可以将许多开发人员特别添加到一项任务中,现在我还希望能够操作我添加到连接表中的其他字段,例如“estimated_time”,“完成时间'......等等......我在Simple_form上得到的是`
<%= simple_form_for [@sprint,@task], :html => { :class => 'form-horizontal' } do |f| %>
<%= f.input :name %>
<%= f.input :description %>
<%= f.association :developers, :as => :check_boxes %>
<div class="form-actions">
<%= f.button :submit, :class => 'btn-primary' %>
<%= link_to t('.cancel', :default => t("helpers.links.cancel")),
project_sprint_path(@sprint.project_id,@sprint), :class => 'btn' %>
</div>
<% end %>`
这仅允许我选择开发人员,我希望能够在那里修改estimated_time 字段。
有什么建议么?