3

在我的应用程序中,我正在努力允许用户发送邀请。邀请有令牌。在电子邮件中,我使用路径中的令牌链接到注册页面。在邮件程序的控制器中,我正在使用:

new_user_registration_url(@invitation.token)

正如我在这个railscast中看到 Ryan Bates 所做的那样。但它似乎正在输出这种格式:

http://localhost:3000/signup.4a4aebcde29738a39c7f447f58817e49cf9b4cf4

为什么有一个“。” 代替 ”/”?

更新:

我正在使用设计,这里是相关的路线。我对这些没有信心;我曾为此苦苦挣扎,但这些似乎有效:

  devise_scope :user do
    get '/signup/:invitation_token' => "registrations#new", :as => :new_user_registration
  end
  devise_for :users, :controllers => { :registrations => "registrations"}, :skip => [:registrations]
  as :user do
    get '/users/cancel' => 'devise/registrations#cancel', :as => :cancel_user_registration
    post '/users' => 'devise/registrations#create', :as => :user_registration
    get '/signup' => 'registrations#new', :as => :new_user_registration
    get '/users/edit' => 'devise/registrations#edit', :as => :edit_user_registration
    put '/users' => 'devise/registrations#update'
    delete '/users' => 'devise/registrations#destroy'
  end
4

2 回答 2

3

很难routes.rb说,但似乎作者有类似的东西:

#in routes.rb
get 'signup' => 'controller#action', as: :new_user_registration

但必须有:

get 'signup/:token' => 'controller#action', as: :new_user_registration

检查:

# in console
app.new_user_registration_path('ToKeN') # => "/signup/ToKeN"
于 2012-04-23T07:50:45.607 回答
0

如果您只是将字符串或符号作为参数传递给路径助手,我认为它会被解释为format. 尝试以下操作:

new_user_registration_url(:token => @invitation.token)

或者

new_user_registration_url + "/" + @invitation.token
于 2012-04-23T07:43:02.360 回答