3

我目前正在尝试将 Active Admin Gem 与已配置有设计的现有 Rails 3.1 应用程序一起使用。此应用程序使用在应用程序控制器中声明的 after_sign_in_path_for 方法。

我按照那里解释的步骤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(self)”中有什么,所以这就是我发布的原因......

谢谢 :-)

这是我的耙子路线

    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"}
4

2 回答 2

2

因为您已经配置了设备。所以你必须从设计中“排除”活动的管理路径。

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

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

config.skip_before_filter :authenticate_user!
于 2014-12-19T08:32:24.897 回答
1

复制评论中的答案,以便从“未回答”过滤器中删除此问题:

实际上问题是我为设计设置了一个 after sign_in 路径,我必须修改它以防我们登录到管理面板。为此,我刚刚添加了一个测试,并在登录到 admin_panel 时使用了关键字“super”来保持 super after_sign_in_path 方法的清洁。这是在此评论中提出的:https ://github.com/gregbell/active_admin/issues/1133#issuecomment-4967768

〜回答大卫法布雷盖特

于 2013-10-09T07:14:40.320 回答