Ruby on rails 以嵌套形式在activeadmin中插入静态内容或某些erb

Ruby on rails 以嵌套形式在activeadmin中插入静态内容或某些erb,ruby-on-rails,activeadmin,Ruby On Rails,Activeadmin,正在尝试在active admin中呈现有关对象的某些信息: f.inputs 'Devices' do f.has_many :devices, new_record: false do |device| "html or some ERB goes here" device.input :status_activated, as: :bool end end 我尝试了以下方法,我发现: device.form\u.last 似乎得到了回答

正在尝试在active admin中呈现有关对象的某些信息:

  f.inputs 'Devices' do
    f.has_many :devices, new_record: false do |device|
     "html or some ERB goes here"  

      device.input :status_activated, as: :bool
    end
  end
我尝试了以下方法,我发现:

device.form\u.last
似乎得到了回答(但未被接受)


有关更多信息,请参阅回购协议。

如果您只有一些简单的HTML,只需执行即可

f.inputs 'Devices' do
    f.has_many :devices, new_record: false do |device|
      span "html or some ERB goes here"  

      device.input :status_activated, as: :bool
    end
end
但是,如果您需要更复杂的内容,最好只提取一个部分,如用
表单部分替换
表单do
块:“表单”
,并将表单布局和数据放在
\u form.html.erb
文件中的
app/views/admin/…

insert_tag(Arbre::HTML::Div) { content_tag(:span, "foo") }
f.inputs 'Devices' do
    f.has_many :devices, new_record: false do |device|
      span "html or some ERB goes here"  

      device.input :status_activated, as: :bool
    end
end