title: undefined method update for nil class
body: <p>After a user logs in, I'm trying to collect additional info to update in the data base</p>
  
  <p>this is my controller</p>
  
  <pre><code>  def show
     @user = User.find(params[:id])
    end
  
    def new
     @user = User.new
    end
  
  
    def additional_info
     @user = User.find params[:id]
    end
  
  
    def update
      if @user.update(user_addinfo)
          redirect_to user_path(@user), notice: 'User was successfully updated.'
      else
          render action: 'additional_info'
      end
    end
  
  
    def create
      @user = User.new(user_params)
      if @user.save
       #session[:user_id] = @user.id
       #UserMailer.welcome_email(@user).deliver
       sign_in @user
       redirect_to  additional_info_path(@user)
       flash[:success] = "Welcome to InYourShoes!"
      else
       render'new'
     end
   end  
  
  private
  
  def user_params 
    params.require(:user).permit(:name, :email, :password, :password_confirmation)
  end
  
  
  def user_addinfo
    params.require(:user).permit(:year)
  end
  end
  </code></pre>
  
  <p>the error occurs at the def update function if @user.update(user_addinfo), rails says its undefined.
  def user_addinfo is a action method and def additional_info is the actual page</p>
  
  <p>the view for the page:</p>
  
  <pre><code>  &lt;div class="row"&gt;
     &lt;div class="col-xs-12 col-sm-6 col-sm-offset-3"&gt;
      &lt;%= form_for(@user, :html =&gt; {:class =&gt; 'form-horizontal'}) do |f| %&gt;
      &lt;fieldset&gt;
       &lt;p&gt;Do you have experience in Business? If yes, select one of the following:
        &lt;div class="input-group"&gt;
          &lt;div class="input-group-btn"&gt;
            &lt;button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"&gt;Select one &lt;span class="caret"&gt;&lt;/span&gt;&lt;/button&gt;
      &lt;ul class="dropdown-menu"&gt;
        &lt;li&gt;&lt;a href="#"&gt;Entrepreneurship&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="#"&gt;Investments&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="#"&gt;Management&lt;/a&gt;&lt;/li&gt;
        &lt;li class="divider"&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="#"&gt;All of the Above&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/div&gt;&lt;!-- /btn-group --&gt;
    &lt;%= f.text_field :year , :class =&gt; "form-control", :placeholder =&gt; "Years of experience" %&gt;
   &lt;/div&gt;
  &lt;/p&gt;
  
  &lt;div class = "center form-actions"&gt;
  &lt;%= f.submit "Submit", class: "btn btn-lg btn-primary" %&gt;
  &lt;/div&gt;
  &lt;/fieldset&gt;
  &lt;% end %&gt; 
   &lt;/div&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>am i saving the @user in the wrong place? I'm still new to the concept of @variablename instance variable... help and explanation is greatly appreciated</p>