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 7622471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:27:45+00:00 2026-05-31T04:27:45+00:00

Following Hartl’s RailTutorial for Rails(3.2). I keep getting this error message or oddly a

  • 0

Following Hartl’s RailTutorial for Rails(3.2). I keep getting this error message or oddly a “The connection was reset” message:

ActiveRecord::RecordNotFound in UsersController#show 
Couldn't find User without an ID

I’m trying to log in and after successfully logging in, I want the application to redirect the user to user/show.html.erb. I believe that I’m passing the :id parameter in the show method in the users controller. Any tip/help would be appreciated!

I’ve pasted some relevant files below. Let me know if you guys need anything else.

sessions_controller.rb

class SessionsController < ApplicationController

def new
  @title = "Log in"
end

def create
  user = User.find_by_email(params[:session][:email])               
  if user.nil?
     flash.now[:error] = "Invalid email/password combination."
      @title = "Sign in"
      render 'new'
   else
     flash.now[:success] = "Successful login!"
     sign_in user
      redirect_to 'users/show'
    end
 end

def destroy
    sign_out
    redirect_to root_path[:name]
end
end

users_controller.rb

class UsersController < ApplicationController


def new
  @user = User.new
  @title = "Sign up"
end

def show
  if params[:id].nil? && current_user
    @user = current_user
  else
    @user = User.find(params[:id])
  end
  @title = @user.name
  end


def create
  @user = User.new(params[:user])
  if @user.save
    sign_in @user
    flash[:success] = "Account created!"
    redirect_to @user
   else
     @title = "Sign up"
     render 'new'
   end
  end

def destroy
  @user.destroy
  redirect_to users_path, :flash => { :success => "User destroyed." }
 end

end

routes.rb

SampleApp::Application.routes.draw do

  resources :users
  resources :sessions, :only => [:new, :create, :destroy]   


  match '/sessions', :to => 'users#show'
  match '/signup', :to => 'users#new'
  match '/login', :to => 'sessions#new'
  match '/logout', :to => 'sessions#destroy'

  root :to => 'pages#home'

Edit: Added sessions_helper.rb

module SessionsHelper

def sign_in(user)
    cookies.permanent.signed[:remember_token] = user.remember_token
    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_from_remember_token
end


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

private

def user_from_remember_token
  remember_token = cookies[:remember_token]
  User.find_by_remember_token(remember_token) unless remember_token.nil?
end



end
  • 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-05-31T04:27:47+00:00Added an answer on May 31, 2026 at 4:27 am

    I think in the def create in session controller you have not passed any id . If you have session user id please pass with it

    Code can be

    redirect_to 'user/show' , :id => session[:user_id]
    redirect_to user_url(:session[:user_id])
    

    Can you please check current_user be. with rendering like

    render :text => current_user.inspect and return false
    in session controller before

    redirect_to user_url(:session[:user_id])
    

    . If it does not come there is a problem in your authentication .

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

Sidebar

Related Questions

I'm following the Rails Tutorial by Michael Hartl and I'm getting an unexpected error/failed
I am running Rails 3.0.1 and Rspec 2.0.1. I am following M. Hartl's Ruby
Following Hartl's railstutorial and I changed my error-messages partial to work with other objects
Following Hartl's railtutorial. When I try to log in, it takes me to the
Hey I was following Michael Hartl's railstutorial when I stumbled upon this chunk of
New to Ruby on Rails and having a problem when following Michael Hartl's tutorial.I'm
I have this test from michael hartl book describe follower/following counts do let(:user) {
I am following the Ruby on Rails tutorial by Michael Hartl http://ruby.railstutorial.org/ I installed
(ruby 1.9.2, rails 3.1) Following Michael Hartl's tutorial. Spent more than a day trying
I'm following Ruby on Rails Tutorial: Learn Rails by Example, by Michael Hartl. http://ruby.railstutorial.org/chapters/a-demo-app#sec:a_micropost_microtour

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.