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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:50:24+00:00 2026-06-10T19:50:24+00:00

I followed tutorial to write a test scenario: when users go to edit info

  • 0

I followed tutorial to write a test scenario: when users go to edit info page but not sign in yet, they will redirected to sign in page, and after they sign in, they will redirected to the edit page. But when i have done all like the tutorial, run the tests and fails, because wrong number of arguments (0 for 1) error.

This is error info:

AuthenticationPages authorization for non-signed-in users when attempting to visit a protected page after signing in should render the desired protected page
Failure/Error: click_button “Sign in”
ArgumentError:
wrong number of arguments (0 for 1)
# ./app/helpers/sessions_helper.rb:31:in redirect_back_or'
# ./app/controllers/sessions_controller.rb:11:in
create’
# (eval):2:in click_button'
# ./spec/requests/authentication_pages_spec.rb:58:in
block (5 levels) in..

This is my spec/requests/authentication_pages_spec.rb

describe "authorization" do

  describe "for non-signed-in users" do
    let(:user) { FactoryGirl.create(:user) }

    describe "when attempting to visit a protected page" do
      before do
        visit edit_user_path(user)
        fill_in "Email", with: user.email
        fill_in "Password", with: user.password
        click_button "Sign in"
      end

      describe "after signing in" do

        it "should render the desired protected page" do
          page.should have_selector('title', text: 'Edit user')
        end
      end
    end    
 .
 .
 .

In app/helpers/sessions_helper.rb, i have two methods, store_location and redirect_back_or to store and redirect back to url address which user visited before sign in:

module SessionsHelper

  .
  .
  .
  def redirect_back_or(default)
    redirect_to(session[:return_to] || default)
    session.delete[:return_to]
  end

  def store_location
    session[:return_to] = request.url
  end
end

Then i used store_location method in app/controllers/users_controller.rb:

class UsersController < ApplicationController

  before_filter :signed_in_user, only: [:edit, :update]
  before_filter :correct_user, only: [:edit, :update]
  .
  .
  private

    def signed_in_user
      unless signed_in?
        store_location
        redirect_to signin_url, notice: "Please sign in."
      end
    end

And i used redirect_back_or method in app/controllers/sessions_controller.rb:

class SessionsController < ApplicationController

  def new

  end

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

I don’t know why this error happen, i think the redirect_back_or method already take argument user but it still error. Anybody can help me solve this? Thanks so much.

  • 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-10T19:50:25+00:00Added an answer on June 10, 2026 at 7:50 pm

    Change this session.delete[:return_to] in your SessionsHelper for this session.delete(:return_to)

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

Sidebar

Related Questions

So, I;m following a tutorial and I followed it exactly but when I test,
I am new to WP7. I followed this tutorial to read and write a
I followed this tutorial . But whenever I try to log in with my
I followed the tutorial on https://dev.twitter.com/docs/auth/implementing-sign-twitter to use OAuth on my homepage. Everything worked
I followed this tutorial but still I go to the webpage refresh, then go
I followed this tutorial Gath Adams Tutorial:How to write a facebook application in 10
I've followed a tutorial to create the socket server below which allows multiple users
I followed this tutorial http://www.vogella.com/articles/AndroidCloudToDeviceMessaging/article.html I wrote the manifest File giving all the permissions
I followed this tutorial to implement facebook into my application. All I want is
I followed this tutorial http://stevejenkins.com/blog/2011/08/how-to-install-apc-alternative-php-cache-on-centos-5-6/ to install apc on my centos vps hosting but

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.