Rails 4: fields_for in fields_for
I am learning RoR and i am trying to find how to set a fields_for in another one with has_one models like this: class Child < ActiveRecord::Base belongs_to :father accepts_nested_attributes_for :father end class Father < ActiveRecord::Base has_one :child belongs_to :grandfather accepts_nested_attributes_for :grandfather end class Grandfather < ActiveRecord::Base has_one :father end I used Nested Model Form Part 1 on Railscasts to get these: In children_controller.rb: def new @child = Child.new father=@child.build_father father.build_grandfather end def child_params params.require(:child)