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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:35:20+00:00 2026-06-01T03:35:20+00:00

In section 9.2.1 of Michael Hartl’s new Rails Tutorial Book (3.2), there is a

  • 0

In section 9.2.1 of Michael Hartl’s new Rails Tutorial Book (3.2), there is a test defined to ensure that if a user is logged in they cannot update (PUT) changes to another user. If this is attempted, the user should be redirected to the home page. Because a webpage can’t directly issue a PUT, the RSPEC test uses:

before { put user_path(wrong_user) }
{ response.should redirect_to(root_path) }

This test case fails and looking at the log it seems to be exiting on because the first before_filter (signed_in_user) in the UserController is redirecting to the sign in page.

Here is my github page for this sample app:
https://github.com/treetopvt/sample_app

  • 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-01T03:35:22+00:00Added an answer on June 1, 2026 at 3:35 am

    In chapter 8 there was an exercise to switch from cookies to sessions. in my SessionsHelper module I replaced

    cookies.permanent[:remember_token] = user.remember_token
    

    with

    session[:remember_token] = user.remember_token
    

    The move to sessions worked fine, but because I was no longer “permanently” storing a cookie, the test fails. I undid my exercise changes from Chapter 8, moving back to cookies, and all tests pass. Now, any ideas on how I change my authorization test to work while using sessions? This is my current test:

                describe "as wrong user" do
                let(:user) { FactoryGirl.create(:user) }
                let(:wrong_user) { FactoryGirl.create(:user, email:"wrong@example.com") }
                before { sign_in user }
    
                describe "Visiting Users#edit page" do
                    before { visit edit_user_path(wrong_user) }
                    it { should have_selector('title', text: full_title('')) }
                end
    
                describe "submitting a PUT request to the Users#update action" do
                    before { put user_path(wrong_user) } #put is an update?
                    specify{ response.should redirect_to(root_path) }
                end
            end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While going through Ruby On Rails Tutorial by Michael Hartl,in the section where the
Doing Michael Hartl's Rails Tutorial, on chapter 10, section 5, exercise 2 . I
In section 6.2.4 of Ruby on Rails 3 Tutorial , Michael Hartl describes a
I am following the Ruby on Rails tutorial by Michael Hartl. In section 6.3.1
I'm going through Michael Hartl's Ruby on Rails 3.2 Tutorial and I'm confused about
I'm following the Rails Tutorial by Michael Hartl and I'm getting an unexpected error/failed
enter code hereI'm trying to finish up Michael Hartl's Ruby on Rails v3.2 Tutorial
I worked through all of Michael Hartl's Ruby on Rails Tutorial with all the
I am completely new to ror and am following Michael Hartl's tutorial but I
I'm running through Michael Hartl's Rails Tutorial . I'm trying to verify the title

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.