Rails使用句點而不是問號生成帳號激活URL。我在郵件程序預覽和rails日誌中看到了這種情況。例如鏈路:從routes.rb中爲什麼Rails會在URL的查詢字符串之前加上句點(點),而不是問號?
http://localhost:3000/account_activations/Cm4OyFOwosBcGZ67qg49nQ/[email protected]
:
resources :account_activations, only: [:edit]
從users_controller.rb:
def create
@user = User.new(user_params)
if @user.save
UserMailer.account_activation(@user).deliver_now
flash[:info] = "Please check your email to activate your account."
redirect_to root_url
else
render 'new'
end
end
從account_activation.html.erb:
<%= link_to "Activate", edit_account_activation_url(@user.activation_token, @user.email) %>
從user.rb(方法來創建並分配摘要):
def create_activation_digest
self.activation_token = User.new_token
self.activation_digest = User.digest(activation_token)
end
從user_mailer_preview.rb:
def account_activation
user = User.first
user.activation_token = User.new_token
UserMailer.account_activation(user)
end
[email protected]看起來像一個電子郵件地址。 –