title: Undefined method `avatar' for nil:NilClass
body: <p>I'm trying to print an image using the Paperclip gem.</p>
  
  <p>When I print using views/devise/edit.html.rb everything looks good but when I want print in views/layout/application.html.rb I'm getting this error in console:</p>
  
  <pre><code>ActionView::Template::Error (undefined method `avatar' for nil:NilClass):
       7:   &lt;%= csrf_meta_tags %&gt;
       8: &lt;/head&gt;
       9: &lt;body&gt;
      10: &lt;%= image_tag @user.avatar.url(:thumb) %&gt;
      11: &lt;%= yield %&gt;
      12: 
      13: &lt;/body&gt;
    app/views/layouts/application.html.erb:10:in `_app_views_layouts_application_html_erb___4291648939640547438_70254980514000'
  </code></pre>
  
  <p>This is User.rb:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    # Include default devise modules. Others available are:
    # :confirmable, :lockable, :timeoutable and :omniauthable
    devise :database_authenticatable, :registerable,
           :recoverable, :rememberable, :trackable, :validatable
  
  has_attached_file :avatar, :styles =&gt; { :medium =&gt; ["300x300&gt;"], :thumb =&gt; ["100x100&gt;"], :page =&gt; ["800"] }
  
  
  end
  </code></pre>
  
  <p>This is application_controller.rb:</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    # Prevent CSRF attacks by raising an exception.
    # For APIs, you may want to use :null_session instead.
   before_action :configure_permitted_parameters, if: :devise_controller?
  
    protected
  
    def configure_permitted_parameters
      devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:first_name, :last_name, :email, :password, :password_confirmation) }
      devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:first_name, :last_name, :email, :password, :password_confirmation, :current_password, :avatar) }
  
  
    end
  
  
  end
  </code></pre>