title: RoR Tutorial chapter 9 (section 9.2.3) tests failed because wrong number of argument (0 for 1)
body: <p>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 <code>wrong number of arguments (0 for 1)</code> error. </p>
  
  <p>
  This is error info:</p>
  
  <blockquote>
    <p>AuthenticationPages authorization for non-signed-in users when attempting to visit a protected page after signing in should render the desired protected page<br>
         Failure/Error: click_button "Sign in"<br>
         ArgumentError:
           wrong number of arguments (0 for 1)<br>
         # ./app/helpers/sessions_helper.rb:31:in <code>redirect_back_or'<br>
         # ./app/controllers/sessions_controller.rb:11:in</code>create'<br>
         # (eval):2:in <code>click_button'
         # ./spec/requests/authentication_pages_spec.rb:58:in</code>block (5 levels) in..</p>
  </blockquote>
  
  <p>This is my spec/requests/authentication_pages_spec.rb  </p>
  
  <pre class="lang-rb prettyprint-override"><code>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    
   .
   .
   .
  </code></pre>
  
  <p>In app/helpers/sessions_helper.rb, i have two methods, <code>store_location</code> and <code>redirect_back_or</code> to store and redirect back to url address which user visited before sign in:  </p>
  
  <pre class="lang-rb prettyprint-override"><code>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
  </code></pre>
  
  <p>Then i used <code>store_location</code> method in app/controllers/users_controller.rb:  </p>
  
  <pre class="lang-rb prettyprint-override"><code>class UsersController &lt; 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
  </code></pre>
  
  <p>And i used <code>redirect_back_or</code> method in app/controllers/sessions_controller.rb:  </p>
  
  <pre class="lang-rb prettyprint-override"><code>class SessionsController &lt; ApplicationController
  
    def new
  
    end
  
    def create
      user = User.find_by_email(params[:email].downcase)
      if user &amp;&amp; user.authenticate(params[:password])
        sign_in user
        redirect_back_or user
      else
        flash.now[:error] = "Invalid email/password combination"
        render 'new'
      end
    end
  </code></pre>
  
  <p>I don't know why this error happen, i think the <code>redirect_back_or</code> method already take argument <code>user</code> but it still error. Anybody can help me solve this? Thanks so much.</p>