I'm attempting to automatically build a child model when its parent is created, as noted in this post. Say I have two models Person
has_one :folder
and I would like to create a folder when the person creates To do this I go into the Person
model and (from the example above) do the following.
has_one :folder
before_create :build_default_folder
private
def build_default_folder
build_folder
true
end
This makes sense, but say Profile
had some attributes that I would like to set an attribute for Folder
based on the Person
's attributes. Like if the person has :person_name
what should I do to set :folder_name
as "[person_name]'s_Folder"?
Thanks for any suggestions.