Not sure to understand correctly what are you trying to do but you might want to take a look at rails nested attributes.
You would have a Foo class like the following:
class Foo < ActiveRecord::Base
has_one :bar
accepts_nested_attributes_for :bar
end
class Bar < ActiveRecord::Base
belongs_to :foo
end
And you could create a new Bar instance directly associated to Foo like so:
foo = Foo.new(bar_attributes: { name: "Bar's name" })
foo.bar.name
#=> "Bar's name"