到这样定义的动作的链接是什么:
ActiveAdmin.register_page "such_page" do
content title: 'A page' do
columns do
column do
render partial: 'index'
end
end
end # content
action_item do
link_to('Perform', 'such_page/much_action')
end
controller do
def much_action
puts 'Wow, actually doing!'
redirect_to 'http://stackoverflow.com'
end
end
我以为该链接就像
action_item
中提到的那样,但是会导致404错误页面。我是否忘记添加一些路由,或者我对ActiveAdmin register_page
和控制器的协作方式有误吗? 最佳答案
在Active Admin页面中,您必须定义一个自定义操作,如下所示:
ActiveAdmin.register_page "such_page" do
#...
action_item do
# please refer to rake routes for the exact route name
link_to('Perform', admin_much_action_path)
end
page_action :much_action do
puts 'Wow, actually doing!'
redirect_to 'http://stackoverflow.com'
end
#...
end
通过使用
page_action
,将自动配置路由。您可以通过调用rake routes
确保该操作可用。参考:http://activeadmin.info/docs/10-custom-pages.html
关于ruby-on-rails - ActiveAdmine register_page和 Controller ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34886704/