我有一个使用 ActiveAdmin gem 的 Rails 3 应用程序。
有没有办法在仪表板页面制作一个表单。与任何模型都无关的表格?就我而言,选择时间段以显示某些统计信息的表单?
我试过了:
form do |f|
f.inputs "test" do
f.input :time, label: "Duration", as: :select, collection: [['24h', 24], ['1 week', '1w'], ['1 month', '1m']]
end
f.actions
end
但我收到了 f.inputs
的“未定义方法错误”。有人有想法吗?
最佳答案
您可能需要像这样创建一个部分表单:
-# admin/whatever/_form.html.haml
= semantic_form_for 'whatever', :url => admin_whatevers_path do |f|
= f.inputs :name => 'tests' do %>
= f.input :time, collection: [['24h', 24], ['1 week', '1w'], ['1 month', '1m']]
并告诉 activeadmin 像这样使用部分:
#admin/whatever.rb
form :partial => 'form'
关于ruby-on-rails - 事件管理员 : form on dashboard not related to any models,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19770863/