【问题标题】:ActiveAdmin page not displaying form_tag form alongside other contentActiveAdmin 页面未与其他内容一起显示 form_tag 表单
【发布时间】:2015-08-19 14:57:11
【问题描述】:

我有一个 ActiveAdmin 页面,我想用它来将各种文件上传到各种控制器:

ActiveAdmin.register_page "Import" do
    content do
        columns do 
            column do
                panel "Overview" do
                    para "This is the admin Import page."
                end
            end
            column do
                panel "Update/Import Matters" do
                    para "This is some info about what this form should take."
                    form_tag import_matters_path, multipart: true do
                        file_field_tag :file
                        submit_tag "Import"
                    end
                end
            end
        end
    end
end

页面显示,但右侧列仅显示带有文本“这是一些信息......”的面板当我注释掉该行时,我得到一个导入按钮但无法上传文件。当我注释掉 submit_tag 和 para 行时,我得到了“选择文件”按钮来选择要导入的文件,但没有别的。

面板似乎无法正确连接表单中的 html,但我自己不清楚如何做到这一点。

【问题讨论】:

    标签: ruby-on-rails ruby forms activeadmin


    【解决方案1】:

    我最终使用了一个似乎可以解决问题的部分。最终面板看起来像这样:

    panel "Update/Import Matters" do
        para "Some info about the form."
        render 'matters_form'
    end
    

    还有/app/views/admin/import/_matters_form.html.erb:

    <%= form_tag import_matters_path, multipart: true do %>
        <%= file_field_tag :file %>
        <%= submit_tag "Import" %>
    <% end %>
    

    这可能不是唯一的方法,但在这种情况下,partials 肯定有效。

    【讨论】:

      猜你喜欢
      • 2023-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-13
      • 1970-01-01
      相关资源
      最近更新 更多