我有这个在我看来:如何使用&&如果得到此语句以正常工作?
<% if user_signed_in? && current_user.has_role? :admin or :editor %>
这将返回该错误:
syntax error, unexpected tSYMBEG, expecting keyword_then or ';' or '\n'
我也试过这样:
<% if user_signed_in? and current_user.has_role? :admin or :editor %>
虽然我没有得到上面的错误,它根本不起作用......即non-signed-in-user
可以访问该if
块内的内容。
这确实有用,但不是很Ruby的惯用语。 – marcamillion 2014-11-03 14:35:24