0
我有一個表單,我正在創建一個新項目。如何從視圖訪問has_many關係?
= form_for(@project, :html => { :class => 'addProjectForm' }) do |f|
#actions
= f.submit
%p
= f.label :name
%br
= f.text_field :name, :class => 'projectName'
%p
= f.label :ticket
%br
= f.text_field :ticket, :class => 'ticket'
%p
= f.label "Crew Member Name"
= f.label "Crew Member Role"
%br
= f.text_field :crew_members.name
= f.collection_select :crew, CrewMember.all, :role, :role
= f.submit "Add More Crew Members", :id => 'add-crew-member'
%p
一切工作正常的點:crew_members.name。我不斷收到undefined method "name" for :crew_member:Symbol
。所有以前的標籤都在更新項目表,但我不能讓CrewMembers更新。這是模型。
class CrewMember < ActiveRecord::Base
attr_accessible :name, :role
belongs_to :project
end
感謝您的幫助提前。
它適合你嗎? – rb512
工作正常。抱歉耽擱了。 – jhamm
沒問題,很高興它的工作! – rb512