First argument in form cannot contain nil or be empty Hartl's Rails 5 Tutorial
<p>I hit a wall during Hartl's Tutorial.
Test below is giving me "First argument in form cannot contain nil or be empty":</p>

<pre><code>require 'test_helper'

class UsersEditTest &lt; ActionDispatch::IntegrationTest

  def setup
    @user = users(:michael)
  end

  test "unsuccessful edit" do
    get edit_user_path(@user)
    assert_template 'users/edit'
    patch user_path(@user), params: { user: { name:  "",
                                              email: "foo@invalid",
                                              password:              "foo",
                                              password_confirmation: "bar" } }

    assert_template 'users/edit'
  end
end
</code></pre>

<p>Here is controller action where I define update method:</p>

<pre><code> class UsersController &lt; ApplicationController

  def show
    @user = User.find(params[:id])
  end

  def new
    @user = User.new
  end

  def create
    @user = User.new(user_params)
    if @user.save
      log_in @user
      flash[:success] = "Welcome to the Sample App!"
      redirect_to @user
    else
      render 'new'
    end
  end

  def update
    @user = User.find(params[:id])
    if @user.update_attributes(user_params)
      # Handle a successful update.
    else
      render 'edit'
    end
  end

  private

    def user_params
      params.require(:user).permit(:name, :email, :password,
                                   :password_confirmation)
    end
end
</code></pre>

<p>And finally html form:</p>

<pre><code>&lt;% provide(:title, "Edit user") %&gt;
&lt;h1&gt;Update your profile&lt;/h1&gt;

&lt;div class="row"&gt;
  &lt;div class="col-md-6 col-md-offset-3"&gt;
    &lt;%= form_for(@user) do |f| %&gt;
      &lt;%= render 'shared/error_messages' %&gt;

      &lt;%= f.label :name %&gt;
      &lt;%= f.text_field :name, class: 'form-control' %&gt;

      &lt;%= f.label :email %&gt;
      &lt;%= f.email_field :email, class: 'form-control' %&gt;

      &lt;%= f.label :password %&gt;
      &lt;%= f.password_field :password, class: 'form-control' %&gt;

      &lt;%= f.label :password_confirmation, "Confirmation" %&gt;
      &lt;%= f.password_field :password_confirmation, class: 'form-control' %&gt;

      &lt;%= f.submit "Save changes", class: "btn btn-primary" %&gt;
    &lt;% end %&gt;

    &lt;div class="gravatar_edit"&gt;
      &lt;%= gravatar_for @user %&gt;
      &lt;a href="http://gravatar.com/emails" target="_blank" rel='noopener'&gt;change&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>What could be the reason? I made sure that @user was properly intialized.</p>