2

在 ActiveAdmin 中,当我在仪表板上按下 action_item 时,我试图从表单中获取一个值,但我不确定如何做到这一点,这就是我到目前为止所拥有的,它运行,但我想能够为不同的方法调用传递参数。

    ActiveAdmin.register_page "Dashboard" do

  menu :priority => 1, :label => proc{ I18n.t("active_admin.dashboard") }

  page_action :scrape, :method => :post do
    #The scraper works, but I don't know how to pass the info
    #from the form from below into this method
   # scrape = Scraper.new
   # scrape.scrape
    redirect_to admin_dashboard_path, :notice => "Ran the scraper!"
  end

  action_item do
    link_to "Run Scraper", admin_dashboard_scrape_path, :method => :post

  end
    content :title => proc{ I18n.t("active_admin.dashboard") } do
      panel  "Run Course Scraper" do
        para "Run the course webscraper to pull current class list and insert into the Course table in the database"
        form do |f|
          f.input "Session"
        end

      end
    end
end

我想得到输入表单,它说会话传递给 page_action :scrape 不知何故,有什么想法吗?

4

1 回答 1

-1

您可以尝试将控制器操作添加到仪表板页面并将 f.buttons 添加到表单等。

我猜使用 javascript 也应该可以工作。

于 2013-05-20T07:51:30.223 回答