# Migrating restful\_authentication

**URL:** <https://www.ruby-forum.com/t/migrating-restful-authentication/187294>\
**Category:** Rails\
**Created:** [April 21, 2010, 10:02am UTC](https://www.ruby-forum.com/t/migrating-restful-authentication/187294 "2010-04-21T10:02:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanC](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@DanC](https://www.ruby-forum.com/u/DanC)\
**Post date:** [April 21, 2010, 10:02am UTC](https://www.ruby-forum.com/t/migrating-restful-authentication/187294/1 "2010-04-21T10:02:54Z")

</div>

Hi,

I was wondering if anyone is familiar with restful\_authentication  
plugin.

I have an app which uses restful\_authentication and I am creating a  
new app which will exist at a seperate url. However, I would like  
users who have registered on app1 to be able to log into app2 without  
having to register again.

For new members I am going to use establish\_connection to save the  
user to 2 databases.

But for existing members I have tried importing the existing columns  
from the user database in app1 (encrypted\_password, salt etc.) to the  
user database in app2 which has the same columns, but the log in does  
not work.

Can anyone suggest why this may be?

Thanks,

Dan

---

<div class="post-metadata">

**Author:** ![DanC](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@DanC](https://www.ruby-forum.com/u/DanC)\
**Post date:** [April 21, 2010, 10:06am UTC](https://www.ruby-forum.com/t/migrating-restful-authentication/187294/2 "2010-04-21T10:06:25Z")

</div>

Why not use the user table in the old DB for everything instead of  
duplicating the information in both tables?

---

<div class="post-metadata">

**Author:** ![DanC](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@DanC](https://www.ruby-forum.com/u/DanC)\
**Post date:** [April 21, 2010, 10:12am UTC](https://www.ruby-forum.com/t/migrating-restful-authentication/187294/3 "2010-04-21T10:12:17Z")

</div>

HI Sharagoz,

How would I do this?

At a guess, I could probably use establish\_connection (point to app1  
DB) in the User.rb and Permission.rb model files of app2

Is there another way?

Thanks for the quick response,

Dan

---

<div class="post-metadata">

**Author:** ![DanC](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@DanC](https://www.ruby-forum.com/u/DanC)\
**Post date:** [April 21, 2010, 10:38am UTC](https://www.ruby-forum.com/t/migrating-restful-authentication/187294/4 "2010-04-21T10:38:02Z")

</div>

Add a new DB connection in database.yml  
other\_db\_development:  
adapter: mysql  
database: other\_db\_development  
(etc)

Then in User.rb make it use that connection like so:  
class User \< ActiveRecord::Base  
establish\_connection(:other\_db\_development)  
end

Every CRUD operation on the User model will now go to that database

Nothing needs to be changed in the code of the other application, as  
the request goes directly to the database.
