Is there a standard way to check for a presentation layout inside a controller in Rails? I am trying to allow the user to define a layout, but it must exist first.
As I know, there is no standard public method. You can use the rudimentary call as follows:
layouts = Dir['app/views/layouts/*'].map {|f| File.basename(f, '.html.erb') # returns 'layout' for 'layout.html.erb' }
Can you use template_exists? which is an alias for exist?
For example: template_exists?("layout_name", "layouts")
template_exists?("layout_name", "layouts")
I think the best way is to store these values ββin a database, to allow the user to choose from this.
Instead of trying to verify what was suggested in the previous post.
Use the layout model and select the user.