0

In a Rails 3 application layout i include a partial for flash messages. While this is ok in most cases, there is a view where I would need flash messages appear in another place; is there a way in layouts/application.html.erb to say something like

<%= render 'layout/messages' unless somecondition %>

where somecondition is something able to detect that I am in 'myview/index'?

kranz
  • 599
  • 1
  • 6
  • 23

1 Answers1

5

Sure is, use params[:controller] and params[:action] actually you should use controller_name and action_name per the Rails documentation

<%= render 'layout/messages' 
  if controller_name == 'myview' && action_name == 'index' %>
Gavin Miller
  • 43,168
  • 21
  • 122
  • 188