試圖從紅寶石2.0升級/ Rails的4.0到2.2的Ruby/Rails的4.2,我登錄到我的應用程序時遇到的奇怪的錯誤(基於由M.哈特爾Rails的教程):Rails redirect_to與Ruby 2.2/Rails 4.2的新行爲?
Controller: SessionsController#create
Instruction: redirect_to root_url
Error message: wrong number of arguments (2 for 1)
這裏是會議控制器:
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
這裏是路線文件:
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
...
我沒有找到關於redirect_to的Rails中的任何升級指南功能。歡迎您的幫助! 謝謝!
這也幫助了我 – 2016-02-17 12:32:32