'or' and '||' - asking for x or y in this situation?
I have the following code in application.html.erb
...
<body>
<div class="container">
<%= render 'layouts/header' %>
<section class="<%= "login_section" if login_or_signup? %>"> #here's
the issue
<% flash.each do |key, value| %>
<div class="flash <%= key %>"><%= value %></div>
<% end %>
<%= yield %>
</section>
<%= render 'layouts/footer' %>
</div>
</body>
...
login_section is a css class that formats the header differently, and I'd
like that to be set only if the current path is /login or /signup - so the
login_or_signup? helper is defined like so:
def login_or_signup?
request.path == login_path || signup_path
end
I've also tried the guts of that as login_path or signup_path, (login_path
|| signup_path), and (login_path or signup_path) but none of them will
evaluate to true correctly ("correctly" being when the path is either
/login or /signup). I've tried writing this as
def login_or_signup?
request.path == login_path
end
and that works as expected.
No comments:
Post a Comment