How to make a layout from a database in rails 4?

Is it possible to read a line from a text field and display it as a layout?

If I use this, it searches for the 1.html.erb file under the layouts:

 layout: '1' 
+6
source share
2 answers

You can pass the layout name in a call to render

 def show @team = Team.find_by name: 'Red Sox' render action: :show, layout: @team.preferred_layout end 
+1
source

Check out http://guides.rubyonrails.org/layouts_and_rendering.html

All official rails are a great resource.

To use text

 render text: "OK" 
-1
source

Source: https://habr.com/ru/post/955181/


All Articles