1

I was using the following code on my site like so

<% if(@cgi.path_info == '/' || @cgi.path_info == '/index') %>
<!--
<% end %>

ANYTHING HERE WHICH SHOULDN'T BE ON THE MAIN PAGE BUT ON ALL OTHER PAGES

<% if(@cgi.path_info == '/' || @cgi.path_info == '/index') %>
-->
<% end %>

This was included in my sites header which allowed me to hide certain code on the homepage of my site but show it on the rest.

Problem is since upgrading Apache to version 2.4 this no longer works.

Can anyone suggest an alternative way of doing this or provide me with an alternative code? best solution would be to use if statement but could do with some help/examples.

user1657967
  • 27
  • 1
  • 1
  • 8

1 Answers1

0

If the problem is with the commenting-out approach, you can just optionally render the content:

<% unless %w( / /index ).include?(@cgi.path_info) %>

  ANYTHING HERE WHICH SHOULDN'T BE ON THE MAIN PAGE BUT ON ALL OTHER PAGES

<% end %>

If the problem is with @cgi then check this question out: How can I find out the current route in Rails?

It could also be more elegant to use nested layouts, as described in this guide: http://guides.rubyonrails.org/layouts_and_rendering.html#using-nested-layouts

Community
  • 1
  • 1
AJcodez
  • 31,780
  • 20
  • 84
  • 118
  • tried <% unless %w( / /index ).include?(@cgi.path_info) %> <% end %> but no joy. Just comments out everything on all pages – user1657967 Jan 24 '13 at 23:42
  • you're missing the point, i was suggesting you *don't* use the commenting-out approach. Start by debugging what `@cgi.path_info` gives you – AJcodez Jan 24 '13 at 23:45
  • hi thanks but the reason I went for the comment out approach is I need a quick fix first. then i need to re look and the pages and use the nested option – user1657967 Jan 24 '13 at 23:46