title: Rails error resource_name - devise help routing and rendering
body: <p>I am trying to render the login view for the Devise gem but I get an error, below is the code I currently have:</p>
  
  <p>This is my <code>views/users/shared/_links.html.erb</code>:</p>
  
  <pre><code>&lt;%- if controller_name != 'sessions' %&gt;
    &lt;%= link_to "Sign in", new_session_path(resource_name) %&gt;&lt;br /&gt;
  &lt;% end -%&gt;
  
  &lt;%- if devise_mapping.registerable? &amp;&amp; controller_name != 'registrations' %&gt;
    &lt;%= link_to "Sign up", new_registration_path(resource_name) %&gt;&lt;br /&gt;
  &lt;% end -%&gt;
  
  &lt;%- if devise_mapping.recoverable? &amp;&amp; controller_name != 'passwords' %&gt;
    &lt;%= link_to "Forgot your password?", new_password_path(resource_name) %&gt;&lt;br /&gt;
  &lt;% end -%&gt;
  
  &lt;%- if devise_mapping.confirmable? &amp;&amp; controller_name != 'confirmations' %&gt;
    &lt;%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %&gt;&lt;br /&gt;
  &lt;% end -%&gt;
  
  &lt;%- if devise_mapping.lockable? &amp;&amp; resource_class.unlock_strategy_enabled?(:email) &amp;&amp; controller_name != 'unlocks' %&gt;
    &lt;%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %&gt;&lt;br /&gt;
  &lt;% end -%&gt;
  
  &lt;%- if devise_mapping.omniauthable? %&gt;
    &lt;%- resource_class.omniauth_providers.each do |provider| %&gt;
      &lt;%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %&gt;&lt;br /&gt;
    &lt;% end -%&gt;
  &lt;% end -%&gt;
  </code></pre>
  
  <p>And my <code>config/routes.rb</code>:</p>
  
  <pre><code>Densidste::Application.routes.draw do
    match 'user/edit' =&gt; 'users#edit', :as =&gt; :edit_current_user
  
    match 'signup' =&gt; 'devise/users#new', :as =&gt; :signup
  
    match 'logout' =&gt; 'devise/sessions#destroy', :as =&gt; :logout
  
    devise_for :users do
      get "login", :to =&gt; "devise/sessions#new"
    end
  
    resources :sessions
  
    resources :users
  
    devise_for :users
  
    resources :aktivs
  
    resources :taggingposts
  
    resources :tags
  
    resources :kommentares
  
    resources :posts
  
    # You can have the root of your site routed with "root"
    # just remember to delete public/index.html.
    root :to =&gt; "public#index"
  end
  </code></pre>
  
  <p>And in my application layout: </p>
  
  <pre><code>&lt;%= render("users/shared/links") %&gt;
  </code></pre>
  
  <p>I get the following error in the <code>_links.html.erb</code> partial:</p>
  
  <pre><code>NameError in Public#index
  
  Showing C:/Rails/Densidste/app/views/users/shared/_links.erb where line #2 raised:
  
  undefined local variable or method `resource_name' for #&lt;#&lt;Class:0x5db76c0&gt;:0x5db6538&gt;
  
  Extracted source (around line #2):
  
  1: &lt;%- if controller_name != 'sessions' %&gt;
  2:   &lt;%= link_to "Sign in", new_session_path(resource_name) %&gt;&lt;br /&gt;
  3: &lt;% end -%&gt;
  4: 
  5: &lt;%- if devise_mapping.registerable? &amp;&amp; controller_name != 'registrations' %&gt;
  
  Trace of template inclusion: app/views/public/index.html.erb
  
  Rails.root: C:/Rails/Densidste
  </code></pre>
  
  <p>Finally, in my application controller I have the following:</p>
  
  <pre><code>before_filter :resource_name
    def resource_name
      if user_signed_in?
        current_user.name
      else
        :user
      end
    end
  end
  </code></pre>
  
  <p>Any help would be much appreciated, thanks!</p>