简体   繁体   English

设计skip_confirmation! 方法确认用户

[英]Devise skip_confirmation! method confirms user

In my Ruby on Rails application I have multi step with wicked gem to create customer registration. 在我的Ruby on Rails应用程序中,我通过邪恶的宝石进行了多步操作来创建客户注册。 I want to send confirmation at the last step so in my controller I use devise method: 我想在最后一步发送确认,因此在我的控制器中,我使用devise方法:

@customer.skip_confirmation!

But this method is not sending confirmation email and automatically confirm customer. 但是这种方法不会发送确认电子邮件并自动确认客户。 I don't want to have confirmed customer when he didn't click the link in mail. 我不想在客户未单击邮件中的链接时对其进行确认。 Is there any way to solve this problem? 有什么办法解决这个问题?

There is a good answer here: 这里有一个很好的答案:

Rails 3 with Devise for Authentication - How do I manually create a user? 具有Devise for Authentication的Rails 3-如何手动创建用户?

It explains that skip_confirmation! 它解释了skip_confirmation! method sets confirmed_at , and also supplies a workaround which allows you to skip confirmation without confirming the user. 方法设置了confirmed_at ,并且还提供了一种变通方法,允许您跳过确认而无需确认用户。

If you don't want confirmation to be sent on create, neither a code to be generated, call skip_confirmation! 如果您不希望在创建时发送确认,也不希望生成任何代码,请调用skip_confirmation!

if you have added in your user.rb (model) the confirmable module, than the confirmation will be send by it self, right after the user have been created. 如果您在user.rb(模型)中添加了可确认模块,则确认将在创建用户后立即由其自行发送。 So you don't need to add something in your controller other than @user.create! 因此,您无需在控制器中添加@ user.create以外的任何内容!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM