[英]Ruby/Rails - How to write this syntax?
I'm using Doorkeeper and if I modify current_user
in any way, like put it in a conditional statement using unless or if, Doorkeeper won't pick it up. 我正在使用Doorkeeper,并且如果我以任何方式修改current_user
,例如将它放在条件语句中,除非使用,否则,Doorkeeper不会选择它。 Is there a simple way I can keep current_user ||
有什么简单的方法可以保持current_user ||
and fit the next two lines containing the session store and redirect to work in one line to the right of the double pipe? 并适合包含会话存储区的下两行,并重定向到双管道右侧的一行中?
resource_owner_authenticator do
current_user ||
session[:after_login_redirect_to] = request.fullpath
redirect_to('/connect')
end
No need to make it a one liner - use a begin block: 无需使其成为一个衬板-使用开始块:
resource_owner_authenticator do
current_user || begin
session[:after_login_redirect_to] = request.fullpath
redirect_to('/connect')
end
end
您当然可以用多行代码来表达,只需将它们放在方括号中即可。
current_user || (session[:after_login_redirect_to] = request.fullpath; redirect_to('/connect'))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.