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

  • Home
  • SEARCH
  • 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 8055675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:27:49+00:00 2026-06-05T08:27:49+00:00

I was doing chapter 8 of Ruby on Rails by Michael Hartl, I finished

  • 0

I was doing chapter 8 of Ruby on Rails by Michael Hartl, I finished the chapter, finally ran my test and got a few errors. I checked if my codes were right by cross checking with Michael Hartl’s github relevant files and also by viewing his recent screencast and yet I cannot seem to figure out the error.

Could you please kindly tell me the error and the solution like what I need to change?

ERRORS

2) Authentication signin with valid information

    ←[31mFailure/Error:←[0m ←[31mbefore { sign_in user }←[0m
     ←[31mNoMethodError:←[0m
       ←[31mundefined method `redirect_back_or' for #<SessionsController:0x4366b
d8>←[0m
←[36m     # ./app/controllers/sessions_controller.rb:10:in `create'←[0m
←[36m     # (eval):2:in `click_button'←[0m
←[36m     # ./spec/support/utilities.rb:13:in `sign_in'←[0m
←[36m     # ./spec/requests/authentication_pages_spec.rb:31:in `block (4 levels)
 in <top (required)>'←[0m

3) Authentication signin with valid information

     ←[31mFailure/Error:←[0m ←[31mbefore { sign_in user }←[0m
     ←[31mNoMethodError:←[0m
       ←[31mundefined method `redirect_back_or' for #<SessionsController:0x43fdd
60>←[0m
←[36m     # ./app/controllers/sessions_controller.rb:10:in `create'←[0m
←[36m     # (eval):2:in `click_button'←[0m
←[36m     # ./spec/support/utilities.rb:13:in `sign_in'←[0m
←[36m     # ./spec/requests/authentication_pages_spec.rb:31:in `block (4 levels)
 in <top (required)>'←[0m

4) Authentication signin with valid information

    ←[31mFailure/Error:←[0m ←[31mbefore { sign_in user }←[0m
     ←[31mNoMethodError:←[0m
       ←[31mundefined method `redirect_back_or' for #<SessionsController:0x44773
38>←[0m
←[36m     # ./app/controllers/sessions_controller.rb:10:in `create'←[0m
←[36m     # (eval):2:in `click_button'←[0m
←[36m     # ./spec/support/utilities.rb:13:in `sign_in'←[0m
←[36m     # ./spec/requests/authentication_pages_spec.rb:31:in `block (4 levels)
 in <top (required)>'←[0m

5) Authentication signin with valid information

    ←[31mFailure/Error:←[0m ←[31mbefore { sign_in user }←[0m
     ←[31mNoMethodError:←[0m
       ←[31mundefined method `redirect_back_or' for #<SessionsController:0x4153f
f8>←[0m
←[36m     # ./app/controllers/sessions_controller.rb:10:in `create'←[0m
←[36m     # (eval):2:in `click_button'←[0m
←[36m     # ./spec/support/utilities.rb:13:in `sign_in'←[0m
←[36m     # ./spec/requests/authentication_pages_spec.rb:31:in `block (4 levels)
 in <top (required)>'←[0m

6) Authentication signin with valid information

    ←[31mFailure/Error:←[0m ←[31mbefore { sign_in user }←[0m
     ←[31mNoMethodError:←[0m
       ←[31mundefined method `redirect_back_or' for #<SessionsController:0x4347f
a8>←[0m
←[36m     # ./app/controllers/sessions_controller.rb:10:in `create'←[0m
←[36m     # (eval):2:in `click_button'←[0m
←[36m     # ./spec/support/utilities.rb:13:in `sign_in'←[0m
←[36m     # ./spec/requests/authentication_pages_spec.rb:31:in `block (4 levels)
 in <top (required)>'←[0m

7) Authentication signin with valid information

    ←[31mFailure/Error:←[0m ←[31mbefore { sign_in user }←[0m
     ←[31mNoMethodError:←[0m
       ←[31mundefined method `redirect_back_or' for #<SessionsController:0x43e1e
d8>←[0m
←[36m     # ./app/controllers/sessions_controller.rb:10:in `create'←[0m
←[36m     # (eval):2:in `click_button'←[0m
←[36m     # ./spec/support/utilities.rb:13:in `sign_in'←[0m
←[36m     # ./spec/requests/authentication_pages_spec.rb:31:in `block (4 levels)
 in <top (required)>'←[0m

8) Authentication signin with valid information followed by signout

    ←[31mFailure/Error:←[0m ←[31mbefore { sign_in user }←[0m
     ←[31mNoMethodError:←[0m
       ←[31mundefined method `redirect_back_or' for #<SessionsController:0x446dc
18>←[0m
←[36m     # ./app/controllers/sessions_controller.rb:10:in `create'←[0m
←[36m     # (eval):2:in `click_button'←[0m
←[36m     # ./spec/support/utilities.rb:13:in `sign_in'←[0m
←[36m     # ./spec/requests/authentication_pages_spec.rb:31:in `block (4 levels)
 in <top (required)>'←[0m

session_conrtoller.rb

class SessionsController < ApplicationController

  def new
  end

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

  def destroy
    sign_out
    redirect_to root_path
  end
end

utilities.rb

include ApplicationHelper

RSpec::Matchers.define :have_error_message do |message|
   match do |page|
    page.should have_selector('div.alert.alert-error', text: 'Invalid')
  end
end

def sign_in(user)
  visit signin_path
  fill_in "Email",    with: user.email
  fill_in "Password", with: user.password
  click_button "Sign in"

  # Sign in when not using Capybara.
  cookies[:remember_token] = user.remember_token
end

authentication_pages_spec.rb

require 'spec_helper'

describe "Authentication" do

  subject { page }

  describe "signin page" do
    before { visit signin_path }

    it { should have_selector('h1',    text: 'Sign in') }
    it { should have_selector('title', text: 'Sign in') }
  end

  describe "signin" do
    before { visit signin_path }

    describe "with invalid information" do
      before { click_button "Sign in" }

      it { should have_selector('title', text: 'Sign in') }
      it { should have_error_message }

      describe "after visiting another page" do
        before { click_link "Home" }
        it { should_not have_error_message }
      end
    end

    describe "with valid information" do
      let(:user) { FactoryGirl.create(:user) }
      before { sign_in user }

      it { should have_selector('title', text: user.name) }
      it { should have_link('Profile',     href: user_path(user)) }
      it { should have_link('Sign out',    href: signout_path) }
      it { should have_link('Settings',    href: edit_user_path(user)) }
      it { should have_link('Users',       href: users_path) }
      it { should_not have_link('Sign in', href: signin_path) }

      describe "followed by signout" do
        before { click_link "Sign out" }
        it { should have_link('Sign in') }
      end
    end
  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-06-05T08:27:51+00:00Added an answer on June 5, 2026 at 8:27 am

    I followed along to an earlier version of this project and like edr says, that method redirect_back_or was defined in app/helpers/sessions_helper.rb.
    Please check to see that its there, then your app should run fine.

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

Sidebar

Related Questions

I am doing Michael Hartl's Rails Tutorial screencast + online book on Chapter 10,
Doing Michael Hartl's Rails Tutorial, on chapter 10, section 5, exercise 2 . I
I'm currently doing Michael Hardtl's Rails Tutorial and in chapter 7 there is a
I was doing the Ruby on Rails tutorial by Martl and closed my terminal
Doing my first SL4 MVVM RIA based application and i ran into the following
I am working through the Ruby-on-Rails3 Tutorial Chapter 8. I have created a form
I'm doing the class compiler design at the chapter of intermediate code. By doing
I am learning Ruby On Rails. I am on a shared hosting with Ruby
I'm doing the first chapter exercises on my Java book and I have been
I am at the end of chapter five doing the exercises. I am supposed

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.