Reputation: 407
I need to display advertisement only on main page of my website (example.com). I've set up a root_url to posts controller:
map.root :controller => "posts", :action => "index"
I have global layout and I want to place in that view IF statement. The problem is that I have no idea how to check that root_url is displaying in certain moment.
Upvotes: 1
Views: 303
Reputation: 1139
This looks like a better solution to me:
Test for some flag in the view to display the section in question. Set the flag in the controller's action you want it to show for (here PostsController#index).
See discussion here:
It's better, because with the same initial effort, later on you can set the flag based on more involved conditions (not only the page address), and for other actions.
Also, keep logic out of views as much as possible.
Upvotes: 1