如何将参数从局部布局传递到局部?

时间:2019-07-19 07:02:01

标签: ruby-on-rails

我想在共享的局部布局form中显示form_layout局部

# views/layouts/shared/_form_layout.html.haml
= form_with(model: record, remote: true) do |form|
  .fields
    = yield
/// other stuff
# views/articles/_form.html.haml
# ?? want to access the form builder here
# views/articles/new.html.haml
= render partial: 'form', layout: 'layouts/shared/form_layout', locals: { record: Article.new }

如何访问部分模板内的FormBuilder对象?

1 个答案:

答案 0 :(得分:0)

您应该尝试此操作

= render layout: "layouts/shared/form_layout", locals: { record: Article.new} do
  # block contents..