Ruby on rails 如何设置以令牌作为查询字符串的路由?

Ruby on rails 如何设置以令牌作为查询字符串的路由?,ruby-on-rails,routes,Ruby On Rails,Routes,我正在使用Desive,并试图使用Desive注册页面的令牌代码,我知道我对设置链接的路径有一些问题。链接看起来像这样 http://localhost:3000/users/sign_up.asdfsdfasdffffffffffffffasdfasdf 在查询字符串和它之间有一个点不起作用 这是我的路线吗 devise_for :users ,:controllers => { :registrations => "registrations" } do

我正在使用Desive,并试图使用Desive注册页面的令牌代码,我知道我对设置链接的路径有一些问题。链接看起来像这样

http://localhost:3000/users/sign_up.asdfsdfasdffffffffffffffasdfasdf
在查询字符串和它之间有一个点不起作用

这是我的路线吗

    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

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

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

由于您已在
routes.rb
文件中放置了
:as=>:reg\u和\u code

您可以尝试以下操作:


reg\u与\u code\u路径(邀请令牌:@token)

您的视图是什么样子的?能否显示您的
rake routes
输出是什么?视图是电子邮件模板您是否通过电子邮件向用户发送注册链接,他们可能在电子邮件中获得的链接是一个句点而不是斜杠?如果是这样的话,那么您可以显示在模板中呈现url的部分。这是一个链接给出的现在路由错误没有路由匹配{:controller=>“registrations”,:action=>“new”,:invitation\u token=>nil}仍然相同的错误给出的现在路由错误没有路由匹配{:controller=>“registrations”,:action=>“new”,:invitation\u token=>nil}确保您的
@token
不是零。