NoMethodError: undefined method `user' for nil:NilClass
<p>I'm trying to create a @link.user but it keeps giving me this 'undefined method' error.</p>

<pre><code>    irb(main):002:0&gt; @link.user
</code></pre>

<blockquote>
  <p>NoMethodError: undefined method <code>user' for nil:NilClass
          from (irb):2
          from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.5.1/lib/rails/commands/console.rb:110:in
  </code>start'
          from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.5.1/lib/rails/commands/console.rb:9:in
  <code>start'
          from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:68:in</code>console'
          from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:39:in <code>run_command!'
          from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.5.1/lib/rails/commands.rb:17:in
  </code>'
          from bin/rails:4:in <code>require'
          from bin/rails:4:in</code>'</p>
</blockquote>

<p><strong>My user.rb</strong></p>

<pre><code>class User &lt; ActiveRecord::Base
     devise :database_authenticatable, :registerable,
            :recoverable, :rememberable, :trackable, :validatable

     has_many :links
 end     
</code></pre>

<p><strong>My link.rb</strong></p>

<pre><code>class Link &lt; ActiveRecord::Base
    belongs_to :user

    def show
    end

end
</code></pre>