in my client_controller.rb
def edit
@client = Client.find(params[:id])
@client.build_address unless @client.address
...
end
…address is nested polymorphic attribute (1:1)
I don’t like to call the build attribute in controller
my question:
is it good idea to automaticly build nested object if it isn’t build yet ?
example:
class Client
has_one :address, :as => :addressable #polymorphic
#...
def address
super || build_address
end
end
question2:
is there better way to do that ?
Implemented like that in project form more than 6 weeks, still no problem at all,
so yeah looks like a good idea in my case, see question comments