title: building a has_one relation with devise user in rails
body: <p>Im new to rails and am having difficulty creating a profile by a devise user</p>
  
  <p>here is the ProfileController:</p>
  
  <pre><code>class ProfilesController &lt; ApplicationController
  
    before_action :set_profile, only: [:show, :edit, :update, :destroy]
    before_action :authenticate_user!
  
  def index
   @profiles = Profile.all
  end
  
  def new
   @profile = current_user.build_profile
  end
  
  def create
  @profile = current_user.build_profiles(profile_params)
  redirect_to profiles_path
  end
  
  def show
  
  end
  
  def edit
  
  end
  
  def update
  @profile.update(profile_params)
  redirect_to(profiles_path(@profile))
  end
  
  def destroy
  @profile.destroy
  redirect_to profiles_path
  end
  
  private
  def profile_params
  params.require(:profile).permit(:university, :degree)
  end
  
  def set_profile
  @profile = Profile.find(params[:id])
  end
  
  end
  </code></pre>
  
  <p>When i run the rails server i can submit the form but nothing is getting stored in the model 'Profile'</p>
  
  <p>here is the index.html.erb where the data should appear:</p>
  
  <pre><code>&lt;h2&gt;profiles&lt;/h2&gt;
  
  &lt;% @profiles.each do |profile| %&gt;
  
    &lt;%= link_to profile do %&gt;
      &lt;%= profile.university %&gt;
    &lt;% end %&gt;
      &lt;%= profile.degree %&gt;
  
  &lt;% end %&gt;
  </code></pre>
  
  <p>user.rb file:</p>
  
  <pre><code>has_one :profile
  </code></pre>
  
  <p>and the profile.rb file:</p>
  
  <pre><code>belongs_to :user
  </code></pre>
  
  <p>nothing seems to be getting saved to the profile model and nothing is getting displayed on the index.html.erb. Also i have created a migration to store user_id in the profile model.</p>
  
  <p>Thank for your help</p>