简体   繁体   English

将所有ActiveAdmin分配给资源

[英]Scope all ActiveAdmin to resource

I'm using Rails 4 and activeadmin master branch on commit fea5d43fd438. 我在提交fea5d43fd438上使用Rails 4和activeadmin master分支。

Currently, I'm having urls like this: 目前,我有这样的网址:

localhost:3000/admin/posts

I'm working on scoping all my resources into another resource (let's say, scoping posts to a blog), so my routes would look like: 我正在将所有资源都限定在另一个资源中(例如,将博客的范围限定),所以我的路线将如下所示:

localhost:3000/my-first-blog/admin/posts

or 要么

localhost:3000/admin/my-first-blog/posts

Both are good, although the first one is preferred. 两者都很好,尽管首选第一个。

I could not find a way to achieve this using ActiveAdmin. 我找不到使用ActiveAdmin实现此目的的方法。 I tried modifying my routes file to this: 我尝试将路由文件修改为此:

Confly::Application.routes.draw do
  resources :blogs, path: '/', do
    ActiveAdmin.routes(self)
  end
end

But ActiveAdmin started complaining about missing path methods. 但是ActiveAdmin开始抱怨缺少路径方法。 I also tried setting a default namespace on the ActiveAdmin initializer, but it didn't work neither. 我也尝试过在ActiveAdmin初始化程序上设置默认名称空间,但是它也不起作用。

Any idea? 任何想法? :) Thank you! :) 谢谢!

I finally solved it using the belongs_to feature: 我终于使用belongs_to功能解决了它:

http://www.activeadmin.info/docs/2-resource-customization.html#belongs_to http://www.activeadmin.info/docs/2-resource-customization.html#belongs_to

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM