f 属性を削除しない限り、ビュー内のネストされたフォームはレンダリングされません。その場合、送信ボタンは機能しません。私には、仕事と雇用主という 2 つのモデルがあります。ここでレールキャストをフォローしています
ジョブ.rb
attr_accessible :title, :location, :employers_attributes,
belongs_to :employers
accepts_nested_attributes_for :employers
雇用主.rb
attr_accessible :companyname, :url
has_many :jobs
jobs_controller.rb
def new
@job = Job.new
@employer = Employer.new
end
_form.html
<%= form_for(@job) do |f| %>
<%= f.label :title %>
<%= f.text_field :title %>
<%= f.label :location %>
<%= f.text_field :location %>
<%= f.fields_for :employers do |builder| %>
<%= builder.label :companyname, "Company Name" %>
<%= builder.text_field :companyname %>
<%= builder.label :url, "Web Address" %>
<%= builder.text_field :url %>
<% end %>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
どんな入力でも素晴らしいでしょう - ありがとう