0

我正在使用设计并尝试在设计注册页面中使用令牌代码,我知道设置链接的路线存在一些问题。链接看起来像这样

http://localhost:3000/users/sign_up.asdfsdfasdffffffffffffffasdfasdf

查询字符串之间有一个点,它不起作用。

我的 routes.rb 是这个

    devise_for :users ,:controllers => { :registrations => "registrations" } do
        #get "/register", :to => "devise/registrations#new"
          get 'users/sign_up/:invitation_token' => "registrations#new", :as =>        :reg_with_code
      end

请帮我设置一个正确的链接,中间的斜线。

这是可能的耙路线

    invitations GET    /invitations(.:format)                     invitations#index
                     POST   /invitations(.:format)                          invitations#create
      new_invitation GET    /invitations/new(.:format)                 invitations#new
     edit_invitation GET    /invitations/:id/edit(.:format)            invitations#edit
          invitation GET    /invitations/:id(.:format)                 invitations#show
                     PUT    /invitations/:id(.:format)                   invitations#update
                     DELETE /invitations/:id(.:format)               
    invitations#destroy
           reg_with_code GET    /users/sign_up/:invitation_token(.:format)    registrations#new
         new_user_session GET    /users/sign_in(.:format)                      devise/sessions#new
            user_session POST   /users/sign_in(.:format)                      devise/sessions#create
    destroy_user_session DELETE /users/sign_out(.:format)                  devise/sessions#destroy
           user_password POST   /users/password(.:format)                  devise/passwords#create
       new_user_password GET    /users/password/new(.:format)              devise/passwords#new
      edit_user_password GET    /users/password/edit(.:format)             devise/passwords#edit
                     PUT    /users/password(.:format)                  devise/passwords#update
 cancel_user_registration GET    /users/cancel(.:format)                    registrations#cancel
       user_registration POST   /users(.:format)                           registrations#create
    new_user_registration GET    /users/sign_up(.:format)                   registrations#new
   edit_user_registration GET    /users/edit(.:format)                      registrations#edit
                     PUT    /users(.:format)                           registrations#update
                     DELETE /users(.:format)                           registrations#destroy
users GET    /users(.:format)                           users#index
                     POST   /users(.:format)                           users#create
               new_user GET    /users/new(.:format)                       users#new
              edit_user GET    /users/:id/edit(.:format)                  users#edit
                user GET    /users/:id(.:format)                       users#show
                     PUT    /users/:id(.:format)                       users#update
                     DELETE /users/:id(.:format)                       users#destroy
                root        /                                          home#index
4

2 回答 2

0

你可以试试这个:

reg_with_code_path(invitation_token: @token)

于 2013-06-17T07:15:09.940 回答
0

在电子邮件模板中,将令牌链接更改为

<%= link_to "Sign Up", reg_with_code_path(@token) %>

因为你已经:as => :reg_with_code在你的routes.rb文件中放了一个。

于 2013-06-17T06:05:55.933 回答