Using || in Case switch in Rails

前端 未结 2 358
醉酒成梦
醉酒成梦 2021-02-04 07:40

I have a partial that I want to display in a layout only when certain pages use that layout. I\'ve set @page_title for all my pages and thought I could use something like this:<

相关标签:
2条回答
  • 2021-02-04 08:17

    Use , instead of || to separate the matches after when. See more about Ruby syntax in http://docs.huihoo.com/ruby/ruby-man-1.4/syntax.html#case.

    0 讨论(0)
  • 2021-02-04 08:18

    This is what you want:

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

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

    0 讨论(0)
提交回复
热议问题