Rails redirect_to new behaviour with Ruby 2.2 / Rails 4.2?

Trying to upgrade from Ruby 2.0 / Rails 4.0 to Ruby 2.2 / Rails 4.2, I face a surprising error when logging into my application (based on Rails Tutorial by M. Hartl):

Controller: SessionsController#create Instruction: redirect_to root_url Error message: wrong number of arguments (2 for 1)

Here is the sessions controller:

class SessionsController < ApplicationController

  def new   end

  def create     user = User.find_by_login(params[:session][:login])     if user && user.authenticate(params[:session][:password])       sign_in user       redirect_to root_url     else       flash.now[:error] = 'Invalid login/password combination'       render 'new'     end   end

  def destroy     sign_out     redirect_to root_url   end

end

Here is the routes file:

ODQStairs::Application.routes.draw do

  resources :requests

#static pages   get '/help', to: "static_pages#help"   get '/about', to: "static_pages#about"   get '/contact', to: "static_pages#contact"

#root definition   root to: "dashboards#home"

#routes   resources :sessions, only: [:new, :create, :destroy]   get '/signin', to: 'sessions#new' , via: :get   match '/signout', to: 'sessions#destroy', via: :delete

  resources :parameters_lists do       resources :parameters   end   ...

I did not find anything in Rails upgrade guides regarding the redirect_to function. Your help is welcome! Thanks!

Could you copy/paste the full error message from the terminal please?

Colin

The full console message is :

ArgumentError (wrong number of arguments (2 for 1)):   app/controllers/sessions_controller.rb:10:in `create'

See the attached screenshot.

Thanks for your help !

Fred

Attachments: http://www.ruby-forum.com/attachment/10501/Screenshot.jpg

Add gem ‘responders’ to your Gemfile. redirect_to was moved to that.

Add gem 'responders' to your Gemfile. redirect_to was moved to that.

It most certainly wasn't (responders gem is about respond_with/ class level respond_to)

Fred

probly the redirect_to is not clean. check its code. (compare w the newly installed railstutorial) usually when you upgrade rails/ruby to maj ver, youd also want to upgrade the gems...

kind regards --botp

It would have been better to copy/paste the error from the server terminal window as I asked, remember many still pay for bandwidth, particularly on mobile devices.

That is rather odd, can you copy/paste the result of rake routes here please.

Assuming that does not show anything odd I would next try to home in on the exact item that is causing the problem, possibly: 1. comment out the offending line and check that the error moves to the second redirect_to just below. 2. modify the line first so as to redirect_to a plain string url, if that fails in the same way it is an issue with redirect_to 3. if 2 now passes then try using root_url with a different function and see if that passes.

Also possibly useful I think to post Gemfile.lock here.

Colin

As suggested bopt, I had a look at my gems versions, I actually missed a few. I updated to the last versions, following gems have been installed: Installing websocket 1.2.1 Installing selenium-webdriver 2.44.0 Installing bootstrap-will_paginate 0.0.10 Installing sass 3.4.12 Installing annotate 2.6.5 Installing globalid 0.3.3

This solved the issue.

Thanks for your help!

Best regards,

Fred