I have a connection between two models: business and address. where the business has a registered_address. I did it as follows.
class Business < ActiveRecord::Base has_one :registered_address, :class_name => "Address", :foreign_key => :business_registered_address_id accepts_nested_attributes_for :registered_address end class Address < ActiveRecord::Base belongs_to :business end
This association works great for my purposes. When I put out a form using:
= form_for @business do |form| = form.inputs :name => "Registered address" do = form.fields_for :registered_address do |address| = address.input :postcode = address.input :line_1 = address.input :line_2 = address.input :line_3 = address.input :town = address.input :county
Nothing is displayed, just an empty set of fields.
When I comment out the line accepts_nested_attributes_for in the business model, it displays (but does not save) all the fields correctly.
Can anyone see what I'm doing wrong?
thanks
source share