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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:01:04+00:00 2026-06-02T20:01:04+00:00

When a non-signed-in user tries to access edit or update actions of the users

  • 0

When a non-signed-in user tries to access edit or update actions of the users controller, the app should redirect (e.g. to signin page or root_path).
App works fine but tests for this are failing with a following error:

Failure/Error: specify { response.should redirect_to(signin_path) }
Expected response to be a redirect to <http://www.example.com/signin> but was a redirect to <https://www.example.com/users/468>
# ./spec/requests/authentication_pages_spec.rb:69:in `block (6 levels) in <top (required)>'

What might be a problem here? How to debug it?

All code is here: https://github.com/tomek-rusilko/miniatury_katalog_2
And failing tests are here: https://github.com/tomek-rusilko/miniatury_katalog_2/blob/master/spec/requests/authentication_pages_spec.rb (lines: 63 and 105)

  • 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-02T20:01:05+00:00Added an answer on June 2, 2026 at 8:01 pm

    Finally had time to re-visit this. I pulled your code from github and had the same problem. I pared the test down to this:

    require 'spec_helper'
    
    describe "A non-signed_in user directly issuing PUT to the update action" do
      before { put user_path(7) }
      specify { response.should redirect_to(signin_path) }          
    end
    

    As you noted, the binding.pry in the controller code did not stop the execution as I thought it would. After a lot of useless digging/googling around, finally noticed in the log/test.log:

    Started PUT "/users/7" for 127.0.0.1 at 2012-05-23 16:17:31 -0400
    Processing by UsersController#update as HTML
      Parameters: {"id"=>"7"}
    Redirected to https://www.example.com/users/7
    Filter chain halted as #<Proc:0x00000102201608@/Users/eric_mccullough/ruby/railstutorial/tomek-rusilko-miniatury_katalog_2-e73d795/vendor/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_controller/metal/force_ssl.rb:28> rendered or redirected
    Completed 301 Moved Permanently in 1ms (ActiveRecord: 0.0ms)
       (0.1ms)  rollback transaction
       (0.1ms)  begin transaction
    

    that it was attempting to use SSL. My version of the Rails Tutorial is only using SSL in production. I removed ‘force_ssl’ from the application_controller.rb and then all tests passed. I’m still new to Rails and didn’t even realize there are logs but I know now!

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

Sidebar

Related Questions

Using Devise, I know how to protect controller actions from non-signed-in users through: before_filter
My signed request looks like this when viewing a non-authorized page. Array ( [algorithm]
I have a Rails 3 App. When the user is not signed in... I
I'm working through http://railstutorial.org (currently working on section 10.4.2 - destroying users). My User
I have a 3rd party non-signed assembly that I want to reference in several
We have 3 possible options: user not signed in user signed in user signed
I have a rails app that is using Devise, with a User model, no
I want to create a newsletter app and users will naturally have to confirm
I have created a Page Tab Facebook App where I want to display different
My application refreshs automatically to facebook login url but my user already signed in

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.