I integrate Devise to my app and here my current codes that I see important for the problem.
here is the my sign out link
<nav class="round">
<ul>
<li>
<%= link_to "Home", root_path%>
</li>
<li>
<%= link_to "Help (learn Bunch-It)", help_path %>
</li>
<% if signed_in? %>
<li>
<%= link_to "Sign out", destroy_user_session_path, :method => :delete %>
</li>
<li>
<%= link_to "Profile "+current_user.user_name, user_path(current_user), :method => :delete %>
</li>
<%else%>
<li>
<%= link_to "Sign in", new_user_session_path %>
</li>
<%end%>
</ul>
</nav>
then route.rb
devise_for :users
#get "sessions/new"
#get "session/new"
resources :users
#resources :sessions, :only => [:new, :create, :destroy]
#get "users/new"
get "pages/home"
get "pages/contact"
get "pages/about"
get "pages/help"
get "results/result"
get 'tree/insertResult' => 'tree#insertResult'
get "tree/deleteFolder" => 'tree#deleteFolder'
get "tree/createFolder" => 'tree#createFolder'
get "tree/deleteResult" => 'tree#deleteResult'
match '/results' , :to => 'results#result'
match '/contact' , :to => 'pages#contact'
match '/about' , :to => 'pages#about'
match '/help' , :to => 'pages#help'
match '/home_index', :to => 'pages#home'
#match '/signin', :to => 'sessions#new'
#match '/signout', :to => 'sessions#destroy'
root :to => 'pages#home'
here is my controller func. for home page
class PagesController < ApplicationController
def home
@title = "Home"
session[:return_to] = request.fullpath
@page = request.path
puts "Welcome home page"
end
...
and finally here is my profile site controller
class UsersController < ApplicationController
before_filter :authenticate_user!, :only => :token
def index
end
def token
end
def show
@title = current_user.user_name
@haveQuery = false
if @newest_query = findNewestQuery
@common_query = commonQuery
@haveQuery = true
else
@haveQuery = false
end
end
The problem is, when I press sign out my app just refresh the profile site or direct me to the profile site, if I am on different site currently. However I want to be directed to the home page of my app instead of profile page. I did whatever I can think of but cannot solve. Any little idea is like a present for me ? 🙂
I had this same problem with my rails 3.2 app. I found that the problem was with my route file. If you are still having trouble with it I would recommend opening the devise gem and poking around.
And in the view some thing like this
And the users model would look like this
EDIT:
Great way to check that stuff out
Also here are my controllers just so that we are mostly on the same page.