我有以下用户模型:
class User < ActiveRecord::Base
has_many :competences
has_many :skills, :through => :competences
accepts_nested_attributes_for :skills
end
以及以下技能模型:
class Skill < ActiveRecord::Base
has_many :competences
has_many :users, :through => :competences
end
能力模型有一个“类型”属性,它是连接模型。在嵌套表单中,如何在保存提交的技能时设置“类型”属性?这是嵌套形式:
<% f.fields_for :skills do |s| %>
<%= s.text_field :name %>
<% end %>