I want to not show a form, but only if current page is NOT the home page
This is what I have so far...
I have my route setup:
root 'projects#index'
My view:
<% if !current_page?(url_for(:controller => 'projects', :action => 'index')) %>
show some stuff
<% end %>
This doesn't show if the url is localhost:3000/projects
But it shows if its localhost:3000
So I need to somehow make sure that if its the homepage, it won't show. Also, I have search parameters for the home page, and I still don't want to show if its like localhost:3000/projects?search=blahblahblah
Use the root_path
helper:
<% unless current_page?(root_path) %>
show some stuff
<% end %>
This doesn't show if the url is
localhost:3000/projects
But it shows if itslocalhost:3000
or:
<% unless current_page?('/') || current_page?('/projects') %>
# '/' the same as root_path
show some stuff
<% end %>
Also, according the documentation
, no need url_for
method:
current_page?(controller: 'projects', action: 'index')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With