Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 铁路条件一条线_Ruby On Rails_Ruby On Rails 3_If Statement - Fatal编程技术网

Ruby on rails 铁路条件一条线

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

我想把这个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 %>
<% 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 }   )%>


但是你最好把这个问题抽象成一个助手。

解释你的确切问题会帮助我们找到正确的方向。请提醒我们接受答案