Rails 4 + Devise:Missing" admins / sign_up"路线

时间:2015-08-28 01:16:40

标签: ruby-on-rails ruby devise admin

我有一个Rails应用程序,v4,只需要修改一些" old"代码 - 我需要为admin model添加一些属性。

当我尝试添加新的管理员用户并设置为浏览器" / admins / sign_up"时,我收到一条错误消息,指出该路线不存在。

好的,所以我检查了所有的Devise路线:

                new_admin_session GET      /admins/sign_in(.:format)                                                          devise/sessions#new
                    admin_session POST     /admins/sign_in(.:format)                                                          devise/sessions#create
            destroy_admin_session DELETE   /admins/admin_logout(.:format)                                                     devise/sessions#destroy
                   admin_password POST     /admins/password(.:format)                                                         devise/passwords#create
               new_admin_password GET      /admins/password/new(.:format)                                                     devise/passwords#new
              edit_admin_password GET      /admins/password/edit(.:format)                                                    devise/passwords#edit
                                  PATCH    /admins/password(.:format)                                                         devise/passwords#update
                                  PUT      /admins/password(.:format)                                                         devise/passwords#update
                 new_user_session GET      /users/login(.:format)                                                             devise/sessions#new
                     user_session POST     /users/login(.:format)                                                             devise/sessions#create
             destroy_user_session DELETE   /users/logout(.:format)                                                            devise/sessions#destroy
                    user_password POST     /users/secret(.:format)                                                            devise/passwords#create
                new_user_password GET      /users/secret/new(.:format)                                                        devise/passwords#new
               edit_user_password GET      /users/secret/edit(.:format)                                                       devise/passwords#edit
                                  PATCH    /users/secret(.:format)                                                            devise/passwords#update
                                  PUT      /users/secret(.:format)                                                            devise/passwords#update

新管理员注册的路线有可能丢失吗?我错过了什么吗?

无论如何,如何添加这条缺失的路线? 当我查看视图时,我发现admins/registrations/中的new.html.erbdevise_for :admins, :path_names => {:sign_out => 'admin_logout'} devise_for :users, :path_names => { :sign_in => 'login', :sign_out => 'logout', :password => 'secret', :confirmation => 'verification', :unlock => 'unlock', :registration => 'register', :sign_up => 'signup' }, :controllers => {:omniauth_callbacks => "omniauth_callbacks", :registrations => "registrations"} ,而且还有一个新管理员的注册表单。

如何显示(在哪个URL下)表单并使用它?

提前谢谢。

编辑:路线

INSERT INTO schema.tablename
VALUES (
  @myProduct,
  @myVersion,
  @myAction,
  NULL,
  @myPath,
  CONVERT(varbinary(MAX),@myBlob),
  myDeviceType,
  @Shortname
)

1 个答案:

答案 0 :(得分:1)

您可以添加缺少的file.on('end',function(){ res.download('myDocument'); }) 路线,如下所示:

/admins/sign_up

这会产生这条路线:

devise_for :admins do
  get '/admins/sign_up' => 'devise/registrations#new'
end

并且应该解决您的问题。

更新

从当前路线文件中删除它:

new_admin_registration GET    /admins/sign_up(.:format)               devise/registrations#new

将此添加到您的路线文件中:

devise_for :admins, :path_names => {:sign_out => 'admin_logout'}