2012-01-22 37 views
1

我將爲我的應用程序後端構建一個管理界面。最佳實踐:管理界面儀表板的命名空間或資源Mongoid

我正在使用Mongoid,我想知道什麼是最好的做我自己的後端接口。

我不能使用active_admin因爲它不適用於mongoid odm。

我有我的路線:

devise_for :admins 
namespace :admin do 
resources :categories 
resources: users 
resources: posts 
. 
. 
. 
end 

我有我的控制器類,例如:

class Admin::CategoriesController < ApplicationController 
    before_filter :authenticate_admin! # assuming you're using devise 
    def index 
    #etc. 
    end 
end 

其更好地利用命名空間和資源?

這是最好的做法是不使用的寶石作爲active_admin,rails_admin,typus建立與他人的ODM或數據庫管理員的界面......等等

回答

1

使用命名空間,但記住這一點:

不要使用相同的字作爲名字空間和資源

namespace :admin 
    resources :categories 
end 

是罰款,只要你沒有一個模型資源名爲admin或廣告做分鐘。否則,您將很難調試或構建適當的路由(admin_foo_bar_path,可能引用admin命名空間或管理資源,這會讓您和rails都感到困惑)。

+0

非常感謝@ez。 – hyperrjas

+0

不客氣 –