我有一个部分,我想仅在特定网页上使用该布局中的布局来显示。我设置@page_title我所有的网页,我想我可以用这样的:

<% case @page_title when "Log in" || "Forgot Your Password" || "Create a New Password" %><%= render :partial => "common/hello-world" -%><% end -%>

但是,在包括只发生标题的页面“登录”,而不是其他的页面上。是||类似这样的语句中禁止使用案例交换机?是否有不同的方式来设置或语句的情况下开关?

谢谢!

有帮助吗?

解决方案

这是你想要什么:

<% case @page_title when "Log in", "Forgot Your Password", "Create a New Password" %><%= render :partial => "common/hello-world" -%><% end -%>

http://docs.huihoo.com/ruby /ruby-man-1.4/syntax.html#case

其他提示

使用,代替||when后的匹配分开。查看更多关于Ruby语法 http://docs.huihoo.com /ruby/ruby-man-1.4/syntax.html#case

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top