I need to place all my flash notices below header, except of one page.
Only on one page I should place it differently.
EDIT
I added in my acton, where I want to use another layout this line:
render :layout => 'show'
and now, when I'm going to show page it gives me:
undefined method `url' for nil:NilClass
but without rendering THIS layout - no errors.
EDIT
Is it possible in Rails ?
Off the top of my head, you could just do a check on the current controller#action in the view to see if our flash messages need to be moved.
Rails passes these params to every view (ex: if we were in the show
action of UsersController
):
params[:controller] #=> users
params[:action] #=> show
We could add a helper to simplify our condition in the view:
# file: app/helpers/application_helper.rb
def move_flash_messages?
params[:controller] == "users" && params[:action] == "show"
end
And then do this simple check in our layout:
# file: app/views/layouts/application.html.haml
- unless move_flash_messages?
= flash_messages
...
- if move_flash_messages?
= flash_messages