문제

It seems there's not a whole lot of documentation out there covering how to add custom fields to a Devise authentication solution in a Rails 3 app.

Along with the required e-mail and password for users to sign up, I'd like a few other custom fields put in and validated and since there are no controllers generated with Devise, how does one do this?

도움이 되었습니까?

해결책

When you do rails generate devise_views all the views for the features you selected will go in your app/views/devise folder. You could simply add the fields defined in your model to those views. If you need to customize the controller, create


class YourModel::DeviseFeaturesController 

by DeviseFeatures I meant RegistrationsController, ConfirmationsController or whichever features you decided to use.

There is a great screencast about it: RailsCasts-customizing-devise

다른 팁

I needed this same thing. There is a great article I found to help me:

http://ykyuen.wordpress.com/2011/03/03/rails-%E2%80%93-add-custom-fields-to-devise-user-model/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top