On Sun, Mar 7, 2010 at 12:29 PM, DanC <[email protected]> wrote:

> The databases both exist on the same server but one is mysql and one
> is postgresql.
>
> It is not clear to me how to implement this though?

I'm sure there's more than one way, but here's a suggestion.

You have a User now
  class User < ActiveRecord::Base
    # whatever
  end

Create a
  class AssociatedUser < User
    establish_connection :associated_site
  end

Define associated_site in your database.yml

Then you can simply "clone" your user
  a_user = AssociatedUser.new
  a_user.attributes= user.attributes
  a_user.save

And done  :-)

Caveat: if this is an existing user (already saved in the first app) then
you probably want to replace the above with something like
  a_user.attributes= user.attributes.except("id")
to avoid clobbering someone else's account.

Serving suggestion, write lots of tests before implementing  :-)
-- 
Hassan Schroeder ------------------------ [email protected]
twitter: @hassan

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to