Hello All,
We have developed the following code in application.rb
def determine_layout if !params[:layout].blank? and params[:layout] == "print" @layout = "print" else @layout = "public" @layout = "admin" if params[:controller] =~ /admin/ end return @layout end
This code allows us to use link with param in URL "layout=print", so the user can preview any page in browser without the menu, header, footer and etc,
in this project we have only 2 layouts, but there are project where we have 30 - 40 layouts, does anybody know how to write this function in best way like
def determine_layout if !params[:layout].blank? and params[:layout] == "print" @layout = "print" else *** by default in controllers *** end return @layout end
Regards, Pavel