views:

53

answers:

1

Hi all, I currently use Authlogic in a web-app to handle user authentication, but have now decided to create a limited API which would seem to require the use of a single_access_token. My question is, how can I apply the migration to existing users?

I thought using something like

 add_column :users, :single_access_token, :string
 User.reset_column_information
 User.find(:all) do |c|
   c.update_attribute :single_access_token, *****
 end

I don't know if this is the best way, or what to put in place of the * to generate a token for all already-registered users.

Thanks

+1  A: 

I think

User.all.each{ |x| x.reset_single_access_token! }

is what you're looking for

jordinl
Thanks for that! I wasn't too far off, but that's exactly what I needed. Cheers.
Steve F