是否可以从文本数据字段中读取字符串并将其呈现为布局?
如果我使用它,它会查找文件 1.html.erb
在布局下:
layout: '1'
最佳答案
您可以在调用中传递布局的名称以进行渲染
def show
@team = Team.find_by name: 'Red Sox'
render action: :show, layout: @team.preferred_layout
end
关于ruby-on-rails - 如何从 Rails 4 中的数据库渲染布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19157708/