ruby on rails 4 - Can't route to /logout with Authlogic -


i've been trying set user authentication in app using authlogic, , i'm sure problem in code can't seem find it. when hit /login link, works expected, /logout wants use instead of delete.

routing.db

rails.application.routes.draw    root 'comments#index'    resources :roles   resources :subjects   resources :comments   resources :topics   resources :users   resources :user_sessions, only: [:create, :destroy]    delete '/logout', to: 'user_sessions#destroy', as: :logout   '/login', to: 'user_sessions#new', as: :login end 

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(user_session_params)     if @user_session.save         flash[:success] = "welcome back!"         redirect_to root_path     else         render :action => :new     end   end    def destroy     current_user_session.destroy     flash[:success] = "goodbye!"     redirect_to root_path   end    private    def user_session_params     params.require(:user_session).permit(:username, :password, :remember_me)   end end 

application.html.erb

<!doctype html> <html>   <head>     <title><%= content_for?(:title) ? yield(:title) : "untitled" %></title>     <%= stylesheet_link_tag "application" %>     <%= javascript_include_tag :defaults %>     <%= csrf_meta_tag %>     <%= yield(:head) %>   </head>   <body>     <div id="user_nav">         <% if current_user %>             <span><%= current_user.username %></span>             <%= link_to "edit profile", edit_user_path(:current) %>             <%= link_to 'sign out', logout_path, :method => :delete %>         <% else %>             <%= link_to "register", new_user_path %>             <%= link_to 'sign in', login_path %>         <% end %>     </div>     <div id="container">       <% flash.each |name, msg| %>         <%= content_tag :div, msg, :id => "flash_#{name}" %>       <% end %>       <%= content_tag :h1, yield(:title) if show_title? %>       <%= yield %>     </div>   </body> </html> 

does here wrong? here's error i'm getting:

start of error page

relevant routes on error page

in application.html.erb file:

change:

<%= javascript_include_tag :defaults %> 

to:

<%= javascript_include_tag "application" %> 

it should work after that!


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -