【发布时间】:2016-12-05 19:12:11
【问题描述】:
我正在使用 Octokit 登录。
helper_method :user
def show
end
def user
client = Octokit::Client.new(access_token: session[:access_token])
begin
@user = client.user
rescue => e
redirect_to root_path
return
end
end
root_path 在配置中
root to: 'home#new'
rescue 执行了,但是 redirect_to 没有工作,它返回到与 main 方法相同的视图。注意:我在许多帖子中读到将 return 修复它,但它没有
【问题讨论】:
-
从 root_path 中删除 ':' 并确保在 config/routes.rb 文件中定义了 root_path。此外,'return false' 以停止进一步执行。
-
@bkunzi01 我拼错了。我更新了帖子。 root 已定义,root_path 已正确定义
标签: ruby-on-rails octokit