Just trying to set up some basic links with authlogic. here they are
<% if current_user %>
<div class="register_new_user">
<%= link_to "Register", new_user_path %>
</div>
<div class="login_existing_user">
<%= link_to "Log In", new_user_session_path %>
</div>
<% else %>
<div class="logout">
<%= link_to "Log Out", :controller => :user_sessions, :action => :destroy %>
</div>
<% end %>
what is also weird is that destroy_user_session_path
doesn't exist, and is what I would prefer to use. But when I click the Logout Link, it just takes me to localhost:3000/user_sessions/
here is my user_sessions controller:
class UserSessionsController < ApplicationController
before_filter :require_no_user, :only => [:new, :create]
before_filter :require_user, :only => :destroy
def new
@user_session = UserSession.new
end
def create
@user_session = UserSession.new(params[:user_session])
if @user_session.save
flash[:notice] = "Login successful!"
redirect_back_or_default account_url
else
render :action => :new
end
end
def destroy
current_user_session.destroy
flash[:notice] = "Logout successful!"
redirect_back_or_default new_user_session_url
end
end
so, I'm confused as to why new_user_session_path
works, and destroy_user_session_path
doesn't.
for reference: my routes:
map.resource :user_session
map.resource :account, :controller => "users"
map.resources :users
map.root :controller => "info", :action => "home"
map.connect "/home", :controller => "info", :action => "home"