I'm trying to setup a nested form and the main thing I can't get working is knowing when to do the build method. Here are my models:
class User < ActiveRecord::Base
belongs_to :address
accepts_nested_attributes_for :address
end
class Address < ActiveRecord::Base
has_one :user
end
In all the examples I've found, which appear to be pre-rails 3, I see the following two methods:
user.address.empty?
user.address.build
I have managed to winnow out with my semi-asleep Google-Fu that the build has been replaced with:
user.build_address
What I'm trying to figure out is what's the replacement for empty? It doesn't appear to exist when I try things at the console, but user.build_address is wonderful.
Any ideas?
thanks...