So I'm going to switch from Authlogic to Devise. Since I only have a couple of test accounts, I thought it would be best to simply remove all the Authlogic stuff and my users table, then setup Devise. I'm using Rails 3. Apart from removing authlogic from my gemfile, removing the user and user_session models/tables, is there anythin开发者_如何转开发g else I need to do?
Yo,
when using devise with all modules your User table should look like this :
id | integer | not null default nextval('contributors_id_seq'::regclass)
email | character varying(255) | not null default ''::character varying
encrypted_password | character varying(128) | not null default ''::character varying
password_salt | character varying(255) | not null default ''::character varying
confirmation_token | character varying(255) |
confirmed_at | timestamp without time zone |
confirmation_sent_at | timestamp without time zone |
reset_password_token | character varying(255) |
remember_token | character varying(255) |
remember_created_at | timestamp without time zone |
sign_in_count | integer | default 0
current_sign_in_at | timestamp without time zone |
last_sign_in_at | timestamp without time zone |
current_sign_in_ip | character varying(255) |
last_sign_in_ip | character varying(255) |
failed_attempts | integer | default 0
unlock_token | character varying(255) |
locked_at | timestamp without time zone |
created_at | timestamp without time zone |
updated_at | timestamp without time zone |
You will have to write a migration to add/rename the columns.
The great thing is that you can change the default encrytor to the one used by Authlogic so you'll be able to migrate smoothly all your existing users...
See : http://github.com/plataformatec/devise/blob/master/lib/devise/encryptors/authlogic_sha512.rb
You can change the encryptor in devise initializer :
config.encryptor = :authlogic_sha512
That should be all :).
Yes and and I have done this and note that you do NOT need to drop / remove the users table (something you'd be unlikely to do in production obviously!), just use a migration(s) to add the above fields. change the encrypter as required and it should be fairly smooth. Make sure the password_salt and encrypted_password fields are named correctly or use a migration to rename them (or possibly can map them somewhere but I didn't find it).
精彩评论