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