Ruby on rails 铁路条件一条线
我想把这个else if语句合并成一行 下面的“我的代码”显示部分URL,但前提是当前URL不是elsif语句中列出的3个URL之一Ruby on rails 铁路条件一条线,ruby-on-rails,ruby-on-rails-3,if-statement,Ruby On Rails,Ruby On Rails 3,If Statement,我想把这个else if语句合并成一行 下面的“我的代码”显示部分URL,但前提是当前URL不是elsif语句中列出的3个URL之一 <% if request.path == landing_path then %> <% elsif request.path == new_company_path then %> <% elsif request.path == edit_user_path(current_user.id) then %> <% e
<% if request.path == landing_path then %>
<% elsif request.path == new_company_path then %>
<% elsif request.path == edit_user_path(current_user.id) then %>
<% else %>
<%= render 'dashboard/user_controls'%>
<% end %>
我正在努力
<% if request.path != (landing_path || new_company_path || edit_user_path(current_user.id) ) then %>
<%= render 'dashboard/user_controls'%>
<% end %>
我做错了什么
谢谢这将起作用:
<%= render 'dashboard/user_controls' if [landing_path, new_company_path, edit_user_path(current_user)].all? {|path| request.path != path } )%>
但是你最好把这个问题抽象成一个助手。解释你的确切问题会帮助我们找到正确的方向。请提醒我们接受答案