在我的应用中,我正致力于允许用户发送邀请。邀请函有令牌。在电子邮件中,我链接到路径中带有令牌的注册页面。在我使用的邮件控制器中:
new_user_registration_url(@invitation.token)
正如我看到瑞安贝茨所做的那样railscast。但它似乎输出了这种格式:
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
答案 0 :(得分:3)
Wihout 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"
答案 1 :(得分:0)
如果你只是将字符串或符号作为参数传递给路径助手,我认为它被解释为format
。尝试以下内容:
new_user_registration_url(:token => @invitation.token)
或
new_user_registration_url + "/" + @invitation.token