简体   繁体   中英

rails: render variable with layout doesn't work

I have the following two lines in my rails 3.2 application. The first one works, the second doesn't - the layout is not applied.

<%= render partial: 'question_pages/question_page', layout: 'layouts/question_page', locals: {question_page: question_page} %>

<%= render question_page, layout: 'layouts/question_page' %>

Any ideas on why I can't pass layout to render variable ?

Edited because of new answer: I patched Rails because I thought this wasn't possible, but the Rails devs told me better:

https://github.com/rails/rails/pull/7169

You can specify a layout by calling render partial: @variable, layout: 'somelayout' . Whenever you include extra options, you have to specify partial: .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM