如何在我的activeAdmin控制器中为collection_action设置activeAdmin自定义页面部分中的“语义表单”标签的url?
我有:
项目.rb
ActiveAdmin.register Item, :as => "MyItems" do
menu :parent => "My", :label => "My Items"
collection_action :add_me, :method => :post do
redirect_to "/" # just for testing
end
end
自定义页面 ActiveAdmin 控制器
ActiveAdmin.register_page "MyItemsCustomPage" do
content do
@items = Item.all
render "item", { :items => @items }
end
end
_item.html.erb(用于自定义页面)
<%= semantic_form_for :item_add_me, :url => add_me_admin_items_path do |f| %>
<%= f.buttons :commit %>
<% end %>
转到自定义页面后,我遇到了错误:
undefined local variable or method `add_me_admin_items_path' for #<#<Class:0x00000006c3ff40>:0x00000005f8bd80>
顺便说一句,语义形式适用admin_items_path
于项目添加操作。
PS。如果我将 url 更改为/admin/items/add_me
并将其设置:method
为:post
,我会收到路由错误:No route matches [POST] "/admin/items/add_me"