Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8165039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:26:52+00:00 2026-06-06T19:26:52+00:00

I’ve done the Michael Hartl’s Tutorial and now I’m using it to build a

  • 0

I’ve done the Michael Hartl’s Tutorial and now I’m using it to build a project. For Authentication/Authorization I’m basically using the same code from the tutorial and the sample app that I built with it. In my project though the signout (destroy session) is not working. After clicking the signout link it does the redirect to the home page but it has the wrong links in the navigation and I can still access pages I shouldn’t be able to (indicating that I’m still signed in) and I can’t figure out what’s wrong. Any ideas?

Sessions Controller

class SessionsController < ApplicationController
 def new
render 'new'
end

def create
user = User.find_by_email(params[:session][:email])
if user && user.authenticate(params[:session][:password])
  sign_in user
  redirect_to user
else
  flash.now[:error] = 'Invalid email/password combination'
  render 'new'
end
end

def destroy
 sign_out
 redirect_to root_path
end
end

Sessions Helper

module SessionsHelper

  def sign_in(user)
cookies.permanent[:remember_token] = user.remember_token
self.current_user = user
end

def signed_in?
!current_user.nil?
end

def current_user=(user)
@current_user = user
end

def current_user
@current_user ||= User.find_by_remember_token(cookies[:remember_token])
end

def current_user?(user)
user == current_user
end

def sign_out
self.current_user = nil
cookies.delete(:remember_token)
end
end

Header Links

  <header>
          <h1><%= link_to image_tag('logo.gif'), root_path %></h1>
           <div id="login-sec">
          <div class="login-row">
            <div class="col">

            <% if signed_in? %>

            <ul>
              <li><%= link_to "Signout", signout_path, method: "delete" %></li>
            </ul>

            <% else %>  

            <ul>
                <li><%= link_to "Forgot Password", "#" %></li>
                <li class="last"><%= link_to "New user register here", signup_path %>               </li>
            </ul>

            <br /><br /><center><%= link_to image_tag('go-btn.png'), signin_path %></center>
            <% end %>

          </div>
        </header>

User Model (where remember token is created)

class User < ActiveRecord::Base
attr_accessible :company, :name, :email, :password, :password_confirmation
has_secure_password

before_save { |user| user.email = email.downcase }
before_save :create_remember_token

validates :name,  presence: true, length: { maximum: 70 }
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, 
                  format: { with: VALID_EMAIL_REGEX },
                  uniqueness: { case_sensitive: false }
validates :password, presence: true, length: { minimum: 6 }
validates :password_confirmation, presence: true        

private

def create_remember_token
  self.remember_token = SecureRandom.urlsafe_base64
end       
end

Routes File

App::Application.routes.draw do
resources :users
resources :sessions, only: [:new, :create, :destroy]

root to: 'static_pages#home'

match '/about',          to: 'static_pages#about'
match '/contact',        to: 'static_pages#contact'
match '/signup',         to: 'users#new'
match '/about-yourself', to: 'users#about-yourself'
match '/signin',         to: 'sessions#new'
match '/signout',        to: 'sessions#destroy', via: :delete
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T19:26:53+00:00Added an answer on June 6, 2026 at 7:26 pm

    Figured it out. I made users before I put in the signout actions, so I could test out the signin and signup actions. No remember token was created for these users so they were always signed in and there was no remember token to destroy

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.