Answer the question
In order to leave comments, you need to log in
Why does the condition fail?
There is:
application.html.erb
<% if !current_page? (root_path || regulation_path || test_path || device_path) %>
<% else %>
<%= render 'banner' %>
<% end -%>
rake routes
root GET /(:locale)(.:format) welcome# test
regulation GET (/:locale)/regulation(.:format) welcome#regulation
test GET (/:locale)/test(.:format) welcome#test
device GET (/:locale)/device(.:format) welcome #device
Required not to render banner on all pages except regulation, test , device.
Login to / ( root ) and /regulation does not display the banner. But when logging into /test and /device it shows up.
What is the reason for this behavior of rails?
Answer the question
In order to leave comments, you need to log in
The behavior is not rails, but ruby.
What is the meaning of:
?
root_path || regulation_path || test_path || device_path - this expression will return the value of the first variable whose value is not nil. Hence current_page? it always works for you with the root_path value. Why it returns true for PATH_INFO / regulation when checking root_path is another question. First you need to "fix it at the conservatory"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question