Reputation: 7099
I need to use part of my application in iframe on another page. So I need to remove layout on these pages.
I added to ApplicationController
layout :current_layout
def current_layout
if params[:layout] == false.to_s
false
else
'main'
end
end
This works until user click on any link in navigation. So I need to add to every link_to in this part of application something like:
link_to 'store', store_path(params.merge({layout: params[:layout]})
I am wondering that maybe I can refactor that and maybe remove this params.merge
from every link?
Upvotes: 0
Views: 56
Reputation: 7815
You could try something like this:
def my_path_helper(string, path_type, params)
link_to(string, polymorphic_path([path_type], params.merge({layout: params[:layout]})))
end
See the docs for polymorphic path here and also this answer that provides an example.
Is this what you were looking for?
Upvotes: 1