2012-04-04 63 views
3

我目前正在尝试将Active Admin Gem与现有Rails 3.1应用程序一起使用,这些应用程序已经使用devise进行了配置。此应用程序使用应用程序控制器中声明的after_sign_in_path_for方法。一般路由到Active Admin - Rails 3.1

我按照那里说明的步骤https://github.com/gregbell/active_admin,事情是,当我尝试访问0.0.0.0:3000/admin或localist:3000/admin时,我直接重定向到我的主路径。

这是我的route.rb文件,

Fish::Application.routes.draw do 

    devise_for :admin_users, ActiveAdmin::Devise.config 

    ActiveAdmin.routes(self) 




    get "goodnewslikes/create" 

    get "goodnewslikes/destroy" 

    resources :goodnews 

    match "goodnews/share/:id" => "Goodnews#share", :as => "share_goodnews" 

    match "churches/:id/changepicture" => "Churches#changepicture", :as => "change_picture_church" 

    resources :churches 



    match "home" => "Application#home", :as => "home"  

    match "currenthome" => "Application#currenthome", :as => "currenthome" 

    match "globalsearch" => "Application#globalsearch", :as => "globalsearch" 

    match "create_commentlike/:comment_id" => "Commentlikes#create", :as => "create_commentlike" 

    resources :commentlikes, :only => [:destroy] 

    match "create_postlike/:post_id" => "Postlikes#create", :as => "create_postlike" 

    resources :postlikes, :only => [:destroy] 


    match "create_goodnewslike/:goodnews_id" => "Goodnewslikes#create", :as => "create_goodnewslike" 

    resources :goodnewslikes, :only => [:destroy] 

    match "create_notifiations/:type/:user_id/:content_id" => "Notifications#create", :as => "create_notification" 

    match "notifications/updateList" => "Notifications#updateList" 

    resources :notifications, :except => [:edit, :create] 

    resources :comments, :except => [:new] 

    match "posts/:id/loadpic" => "Posts#loadpic", :as => "load_post_pic" 

    match "comments/new/:post_id" => "Comments#new", :as => "new_comment" 

    resources :friendships 

    get "friendships/:id/accept" => "Friendships#accept", :as => "accept_friendship" 

    get "friendships/:id/block" => "Friendships#block", :as => "block_friendship" 


get "users/searching" => "Users#searching", :as => "searching_users" 
    resources :users, :only => [:index, :show] do 
    match "profils/nouveau" => "Profils#new", :as => "new_profil" 
    match "profils/:id/modifier" => "Profils#edit", :as => "edit_profil" 
    resources :profils 
    end 


match "users/search" => "Users#search", :as => "search_users" 



    match "posts_of/:user_id" => "Posts#index", :as => "posts_of" 

    resources :posts 





    devise_for :users, :path_prefix => "d" 



    root :to => "Application#home" 

    match "*path" => 'application#handle_404' 
    # The priority is based upon order of creation: 
    # first created -> highest priority. 

    # Sample of regular route: 
    # match 'products/:id' => 'catalog#view' 
    # Keep in mind you can assign values other than :controller and :action 

    # Sample of named route: 
    # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase 
    # This route can be invoked with purchase_url(:id => product.id) 

    # Sample resource route (maps HTTP verbs to controller actions automatically): 
    # resources :products 

    # Sample resource route with options: 
    # resources :products do 
    #  member do 
    #  get 'short' 
    #  post 'toggle' 
    #  end 
    # 
    #  collection do 
    #  get 'sold' 
    #  end 
    # end 

    # Sample resource route with sub-resources: 
    # resources :products do 
    #  resources :comments, :sales 
    #  resource :seller 
    # end 

    # Sample resource route with more complex sub-resources 
    # resources :products do 
    #  resources :comments 
    #  resources :sales do 
    #  get 'recent', :on => :collection 
    #  end 
    # end 

    # Sample resource route within a namespace: 
    # namespace :admin do 
    #  # Directs /admin/products/* to Admin::ProductsController 
    #  # (app/controllers/admin/products_controller.rb) 
    #  resources :products 
    # end 

    # You can have the root of your site routed with "root" 
    # just remember to delete public/index.html. 
    # root :to => 'welcome#index' 

    # See how all your routes lay out with "rake routes" 

    # This is a legacy wild controller route that's not recommended for RESTful applications. 
    # Note: This route will make all actions in every controller accessible via GET requests. 
    # match ':controller(/:action(/:id(.:format)))' 
end 

任何想法?我不知道什么是在“ActiveAdmin.routes(个体经营)”所以这就是为什么我张贴...

感谢:-)

这是我的耙路线

new_admin_user_session GET  /admin/login(.:format)         {:action=>"new", :controller=>"active_admin/devise/sessions"} 
     admin_user_session POST  /admin/login(.:format)         {:action=>"create", :controller=>"active_admin/devise/sessions"} 
destroy_admin_user_session DELETE|GET /admin/logout(.:format)         {:action=>"destroy", :controller=>"active_admin/devise/sessions"} 
     admin_user_password POST  /admin/password(.:format)         {:action=>"create", :controller=>"active_admin/devise/passwords"} 
    new_admin_user_password GET  /admin/password/new(.:format)        {:action=>"new", :controller=>"active_admin/devise/passwords"} 
    edit_admin_user_password GET  /admin/password/edit(.:format)       {:action=>"edit", :controller=>"active_admin/devise/passwords"} 
          PUT  /admin/password(.:format)         {:action=>"update", :controller=>"active_admin/devise/passwords"} 
      admin_dashboard   /admin(.:format)           {:action=>"index", :controller=>"admin/dashboard"} 
     admin_admin_users GET  /admin/admin_users(.:format)        {:action=>"index", :controller=>"admin/admin_users"} 
          POST  /admin/admin_users(.:format)        {:action=>"create", :controller=>"admin/admin_users"} 
     new_admin_admin_user GET  /admin/admin_users/new(.:format)       {:action=>"new", :controller=>"admin/admin_users"} 
    edit_admin_admin_user GET  /admin/admin_users/:id/edit(.:format)      {:action=>"edit", :controller=>"admin/admin_users"} 
      admin_admin_user GET  /admin/admin_users/:id(.:format)       {:action=>"show", :controller=>"admin/admin_users"} 
          PUT  /admin/admin_users/:id(.:format)       {:action=>"update", :controller=>"admin/admin_users"} 
          DELETE  /admin/admin_users/:id(.:format)       {:action=>"destroy", :controller=>"admin/admin_users"} 
+3

出来的东西,当你'耙routes' – DVG 2012-04-04 19:28:17

+0

太好了!你可以发布admin/dashboard#index的代码吗? – DVG 2012-04-05 14:18:30

+1

其实问题在于我为devise设置了一个sign_in路径,如果我们登录到管理面板,我必须修改它。为此,我只是添加了一个测试,并使用关键字“超级”来保持超级after_sign_in_path方法清理时登录到admin_panel。这是在这个评论中提出的:https://github.com/gregbell/active_admin/issues/1133#issuecomment-4967768 – 2012-04-10 15:28:52

回答

1

复制评论的答案是为了从“未回答”过滤器中删除此问题:

其实问题是我为devise设置了一个后sign_in路径,我必须修改它,以防我们登录到管理面板。为此,我只是添加了一个测试,并使用关键字“超级”来保持超级after_sign_in_path方法清理时登录到admin_panel。该建议在此评论:https://github.com/gregbell/active_admin/issues/1133#issuecomment-4967768

〜每David Fabreguette答案

2

因为你已经配置了色器件。所以你必须“除了”设计中的活动管理路径。

您的路径localhost:3000/admin由devise检查,您是否登录,如果没有它会将您重定向到您的主页。

此行添加到您的app->config->initializers->active_admin.rb文件:

config.skip_before_filter :authenticate_user! 
+0

这正是我在使用Rails 4.2应用程序时所做的,但它不能解决问题。 – damianesteban 2015-02-13 21:49:06