2012-08-15 57 views
6

我有設計安裝。
我有一個鏈接:<%= link_to "Sign up", new_user_registration_path %>Rails:我安裝了ActiveAdmin,我的設計鏈接停止工作

當我安裝ActiveAdmin(現有示範User),這個環節停止工作:

undefined local variable or method `new_user_registration_path' 

我用git的差異爲routes.rb這裏是(補充線黑色):

ActiveAdmin.routes(self)
devise_for :users, ActiveAdmin::Devise.config

而且<%= link_to "Sign out", destroy_user_session_path, :method => :delete %>現在導致/admin/logout

我怎樣才能解決這個問題?

耙路線:

 admin_dashboard   /admin(.:format)      {:action=>"index", :controller=>"admin/dashboard"} 
     admin_codes GET  /admin/codes(.:format)     {:action=>"index", :controller=>"admin/codes"} 
        POST  /admin/codes(.:format)     {:action=>"create", :controller=>"admin/codes"} 
     new_admin_code GET  /admin/codes/new(.:format)    {:action=>"new", :controller=>"admin/codes"} 
    edit_admin_code GET  /admin/codes/:id/edit(.:format)  {:action=>"edit", :controller=>"admin/codes"} 
      admin_code GET  /admin/codes/:id(.:format)    {:action=>"show", :controller=>"admin/codes"} 
        PUT  /admin/codes/:id(.:format)    {:action=>"update", :controller=>"admin/codes"} 
        DELETE  /admin/codes/:id(.:format)    {:action=>"destroy", :controller=>"admin/codes"} 
     admin_users GET  /admin/users(.:format)     {:action=>"index", :controller=>"admin/users"} 
        POST  /admin/users(.:format)     {:action=>"create", :controller=>"admin/users"} 
     new_admin_user GET  /admin/users/new(.:format)    {:action=>"new", :controller=>"admin/users"} 
    edit_admin_user GET  /admin/users/:id/edit(.:format)  {:action=>"edit", :controller=>"admin/users"} 
      admin_user GET  /admin/users/:id(.:format)    {:action=>"show", :controller=>"admin/users"} 
        PUT  /admin/users/:id(.:format)    {:action=>"update", :controller=>"admin/users"} 
        DELETE  /admin/users/:id(.:format)    {:action=>"destroy", :controller=>"admin/users"} 
     admin_comments GET  /admin/comments(.:format)    {:action=>"index", :controller=>"admin/comments"} 
        POST  /admin/comments(.:format)    {:action=>"create", :controller=>"admin/comments"} 
    new_admin_comment GET  /admin/comments/new(.:format)   {:action=>"new", :controller=>"admin/comments"} 
    edit_admin_comment GET  /admin/comments/:id/edit(.:format)  {:action=>"edit", :controller=>"admin/comments"} 
     admin_comment GET  /admin/comments/:id(.:format)   {:action=>"show", :controller=>"admin/comments"} 
        PUT  /admin/comments/:id(.:format)   {:action=>"update", :controller=>"admin/comments"} 
        DELETE  /admin/comments/:id(.:format)   {:action=>"destroy", :controller=>"admin/comments"} 
    new_user_session GET  /admin/login(.:format)     {:action=>"new", :controller=>"active_admin/devise/sessions"} 
     user_session POST  /admin/login(.:format)     {:action=>"create", :controller=>"active_admin/devise/sessions"} 
destroy_user_session DELETE|GET /admin/logout(.:format)    {:action=>"destroy", :controller=>"active_admin/devise/sessions"} 
     user_password POST  /admin/password(.:format)    {:action=>"create", :controller=>"active_admin/devise/passwords"} 
    new_user_password GET  /admin/password/new(.:format)   {:action=>"new", :controller=>"active_admin/devise/passwords"} 
    edit_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"} 
       root   /         {:controller=>"codes", :action=>"list"} 
           /:controller(/:action(/:id(.:format))) 

我檢查了舊版本,並途徑爲:

 new_user_session GET /users/sign_in(.:format)    {:action=>"new", :controller=>"devise/sessions"} 
      user_session POST /users/sign_in(.:format)    {:action=>"create", :controller=>"devise/sessions"} 
    destroy_user_session DELETE /users/sign_out(.:format)    {:action=>"destroy", :controller=>"devise/sessions"} 
      user_password POST /users/password(.:format)    {:action=>"create", :controller=>"devise/passwords"} 
     new_user_password GET /users/password/new(.:format)   {:action=>"new", :controller=>"devise/passwords"} 
     edit_user_password GET /users/password/edit(.:format)   {:action=>"edit", :controller=>"devise/passwords"} 
         PUT /users/password(.:format)    {:action=>"update", :controller=>"devise/passwords"} 
cancel_user_registration GET /users/cancel(.:format)    {:action=>"cancel", :controller=>"devise/registrations"} 
     user_registration POST /users(.:format)      {:action=>"create", :controller=>"devise/registrations"} 
    new_user_registration GET /users/sign_up(.:format)    {:action=>"new", :controller=>"devise/registrations"} 
    edit_user_registration GET /users/edit(.:format)     {:action=>"edit", :controller=>"devise/registrations"} 
         PUT /users(.:format)      {:action=>"update", :controller=>"devise/registrations"} 
         DELETE /users(.:format)      {:action=>"destroy", :controller=>"devise/registrations"} 
+1

運行'rake routes'並列出輸出pls。 – n0denine 2012-08-15 01:59:39

回答

1

看來你正在使用正常用戶和管理員用戶相同的模型。 ActiveAdmin需要管理員使用單獨的模型。試試恢復由發電機所做的更改,然後運行這個:

rails generate active_admin:resource AdminUser 
rake db:migrate 

這將創建一個AdminUser模型,絕對不會有你的網站的用戶鏈接。

+0

問題是AA不需要單獨的模型(我可以選擇AA安裝上的任何模型)。我想使用相同的模型。 – DmitryR 2012-08-15 11:37:08

+0

鑑於上述評論你爲什麼標記答案是正確的?如您所述,Active Admin在其文檔中特別聲明不需要單獨的模型 – sixty4bit 2014-08-21 21:00:10

1

在routes.rb中,指定devise_for:用戶 這將恢復用戶設計的路線

11

有一件事你可能會丟失正在申報您的用戶模型「可註冊」,以獲得通過設計產生的註冊途徑。

你應該有這樣的事情:

class User < ActiveRecord::Base 
    # Include devise modules 
    devise :database_authenticatable, :registerable, ... 

我就遇到了這個問題,一次,這就是解決它。

+2

我認爲activeadmin安裝程序會更新您指定的模型,在您使用的情況下它是User並且必須刪除:regisrable。像這裏建議的那樣重新添加這個解決了這個問題。 – Kevin 2015-03-31 17:49:18