I have an Advisor model with has_one relation to Profile model, in my controller i have a profile page with following code:
@advisor = Advisor.includes(:profile).find(current_advisor_user.id)
@advisor.profile ||= AdvisorProfile.new
When i load that profile page – it create a record in database for profile, however i just want to initialise it so it is not nil in my form.
Try this,
It will return “a new object of the associated type that has been instantiated with attributes and linked to this object through a foreign key, but has not yet been saved.” See this.