title: Click_button in RSpec causes 'Missing required keys: [:id]'
body: <p>This is my spec file where I want to test adding players:</p>
  
  <pre><code>RSpec.describe "AddPlayers", type: :request do
    describe "add player" do
      let(:player) { FactoryGirl.create :player }
      it "add new player with valid data" do
        visit new_player_path
        fill_in "player_firstname", with: player.firstname
        fill_in "player_lastname", with: player.lastname
        fill_in "player_nickname", with: player.nickname
  
        click_button "Add player"
      end
    end
  end
  </code></pre>
  
  <p>And when I run test I get:</p>
  
  <blockquote>
  <pre><code> Failure/Error: click_button "Add player"
   ActionController::UrlGenerationError:
     No route matches {:action=&gt;"show", :controller=&gt;"players", :id=&gt;nil} missing required keys: [:id]
  </code></pre>
  </blockquote>
  
  <p>My FactoryGirls named <code>players.rb</code> looks like here:</p>
  
  <pre><code>FactoryGirl.define do
    factory :player do
      firstname "John"
      lastname "Smith"
      nickname "smithy99"
      avatar { File.new(Rails.root.join('spec/images/1.png')) }
    end
  end
  </code></pre>
  
  <p>My Controller looks like here:</p>
  
  <pre><code>  def new
      @player = Player.new
    end
  
    def create
      @player = Player.create(player_params)
      redirect_to player_path(@player)
    end
  </code></pre>
  
  <p>And my <code>Player</code> model:</p>
  
  <pre><code>class Player &lt; ActiveRecord::Base
    validates :nickname, presence: true, uniqueness: true;
    validates :firstname, :lastname, presence: true;
    has_attached_file :avatar, :styles =&gt; { :medium =&gt; "300x300&gt;", :thumb =&gt; "100x100&gt;" }
    validates_attachment_content_type :avatar, :content_type =&gt; /\Aimage\/.*\Z/
  
    def full_name
      "#{firstname} #{lastname} (#{nickname})"
    end
  # other custom methods...
  end
  </code></pre>
  
  <p>And when I go in my browser to link: </p>
  
  <blockquote>
    <p><a href="http://localhost:3000/players/new" rel="nofollow">http://localhost:3000/players/new</a></p>
  </blockquote>
  
  <p>and click "Add Player" without filing input fields I get the same error like in RSpec: </p>
  
  <blockquote>
    <p>No route matches {:action=>"show", :controller=>"players", :id=>nil}
    missing required keys: [:id]</p>
  </blockquote>
  
  <p>So my question is what is the problem with my spec and how to deal with it? Why <code>player</code> created by FactoryGirl has not <code>id</code>?</p>