开发者

Rails 3 - Different Devise Options for the first User

I'm using Devise in my Rails 3.0.10 app where the开发者_运维百科 Users that sign up must reply to the email Devise generates automatically.

But I wonder, how can I make Devise ignore this option for the first user that will sign up, and request email confirmation for the n next users?

Thanks in advance.


I couldn't think for a good reason to do this. Normally the first user is the administrator (or the owner) and he/she should never have to register. What I usually do is create the first user through a seed:

# db/seeds.rb
...
User.create!(email: "first@user.com", password: "YayIAm1AndHaveADifficultPassword")
...

Then when I have to deploy (this probably will go into capistrano but anyway) you run:

rake db:seed

This way you don't have to hack Devise to not to send the first user a confirmation e-mail.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜