Reputation: 31
I have problem adding a nested model to a form. Specifically, nothing appears in this form section.
new.html.erb
<%= render 'form' %>
_form.html.erb
...
<% fields_for :bigip do |f| %>
<%= f.text_field :bgname %>
<%= f.text_field :bguser %>
<%= f.text_field :bgpassword %>
<% end %>
...
Here are the underlying models and controllers.
pool.rb
class Pool < ApplicationRecord
has_one :bigip, inverse_of: :pool
accepts_nested_attributes_for :bigip, :allow_destroy => true
end
bigip.rb
class Bigip < ApplicationRecord
belongs_to :pool
end
pools_controller.rb
def new
@pool = Pool.new
@pool.build_bigip
end
Upvotes: 2
Views: 343
Reputation: 31
devil is in details :)
I simply missed "=" in line "<% fields_for :bigip do |f| %>"
Upvotes: 1