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!
--
Posted via
http://www.ruby-forum.com/.