6

是否可以从文本数据字段中读取字符串并将其呈现为布局?

1.html.erb如果我使用它,它会在布局下查找文件:

layout: '1'
4

2 回答 2

1

您可以在调用中传递布局的名称来渲染

def show
  @team = Team.find_by name: 'Red Sox'
  render action: :show, layout: @team.preferred_layout
end
于 2013-11-07T20:45:23.010 回答
-1

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

All of the official rails docs are a great resource

To render text use

render text: "OK"
于 2013-10-06T02:55:33.810 回答