ActiveAdmin多个具有相同名称的方法,不同的方法

时间:2018-09-06 05:45:07

标签: activeadmin

我需要处理未连接到任何模型的自定义资源。 它应该处理GET,POST,DELETE方法。网址应为service/measure

所以我是这样创建的:

ActiveAdmin.register_page "Service", :namespace => :admin do
  content do
    link_to 'Stop measure', :admin_service_measure, method: :delete
    panel "Measure RSSI" do
      active_admin_form_for 'Measure' do |f|
        f.inputs do 
          input :name
          actions do
            action :submit, label: "start measure"
          end
        end
      end
    end
  end
  page_action :measure, method: 'post', :url=>'measure' do
    #do something else and
    redirect_to :admin_service, notice: 'Started measure'
  end
  page_action :measure, method: 'delete' do
    #do something and 
    redirect link_to :service
  end
  page_action :measure, method: 'get' do
    #render some view
  end
end

0 个答案:

没有答案