I’m developing an aplication in rails, and need to connect to a
diferente database to set up a migration tool, from an old aplication in
php to the new application in rails
So, I need a “low level” con to the old app so I can transfer the data.
And I need to do it in rails to reuse the app already done in rails. Can
someone help ?
When I need to do this, I create a script that loads up the rails
environment so I have access to all the application stuff, and then
use a manual database connection. Let’s say we’re importing customers
from an old database:
customers = []
while old_customer = old_customers.fetch_hash do
customers << {:name => customer[“Name”], :address =>
customer[“Add”]}
end
Customer.create(customers)
dbh.close
There is more information about ruby-mysql here: http://www.kitebird.com/articles/ruby-mysql.html. You could also use
the rails connection adapters to query the old database - I just
haven’t done that yet :0)