How to call correctly methods from a model relating to other controllers?
In my Ruby on Rails application I want to create a new profile and a new statistic for profile, all calling first the related method from the user model, and then from the profile model. 

So... 

... in my user model (user.rb) I have this:

    ...

    has_one :profile

    ...
    before_save :inizialize_user
    ...

    private
    
    def inizialize_user
      @user_profile = Profile.new
      self.user_profile_id = @user_profile.id
    end


... in my profile model (profiles.rb) I have this:

    ...
    belongs_to :user
    ...
    
    before_save :inizialize_profile
    
    private
    
    def inizialize_profile
      @profile_statistic = ProfileStatistic.new
    end




In the second block of code, on the "before_save" it instantiates a new profile statistic:
"inspecting" @profile_statistic results a new object (correct!)


In the first block of code, on the "before_save" it doesn't instantiate a new profile:
"inspecting" the @user_profile results nil (it must be a new profile object!)


The last part is my problem. Why it happens?
How to call correctly methods from a model relating to other controllers?
===

In my Ruby on Rails application I want to create a new profile and a new statistic for profile, all calling first the related method from the user model, and then from the profile model. 

So... 

... in my user model (user.rb) I have this:

    ...

    has_one :profile

    ...
    before_save :inizialize_user
    ...

    private
    
    def inizialize_user
      @user_profile = Profile.new
      self.user_profile_id = @user_profile.id
    end


... in my profile model (profiles.rb) I have this:

    ...
    belongs_to :user
    ...
    
    before_save :inizialize_profile
    
    private
    
    def inizialize_profile
      @profile_statistic = ProfileStatistic.new
    end




In the second block of code, on the "before_save" it instantiates a new profile statistic:
"inspecting" @profile_statistic results a new object (correct!)


In the first block of code, on the "before_save" it doesn't instantiate a new profile:
"inspecting" the @user_profile results nil (it must be a new profile object!)


The last part is my problem. Why it happens?