attempt_login
提交登录表单后,使用Ajax调用以下方法。
class AccessController < ApplicationController
[...]
def attempt_login
authorized_user = User.authenticate(params[:username], params[:password])
if authorized_user
session[:user_id] = authorized_user.id
session[:username] = authorized_user.username
flash[:notice] = "Hello #{authorized_user.name}."
redirect_to(:controller => 'jobs', :action => 'index')
else
[...]
end
end
end
问题是那redirect_to
行不通。
您将如何解决?
render :js => "window.location = '#{jobs_path}'"