Du kan bruge mysql2 gem direkte. Læs dokumentationen her:https://github.com/brianmario/mysql2
Eller:
Du kan oprette en ny klasse som MysqlConnection sådan her:
class MysqlConnection < ActiveRecord::Base
self.establish_connection(:adapter => 'mysql', :database => 'some-database-name') # Set all the other required params like host, user-name, etc
end
Fra nu af kan du gøre,
MysqlConnection.connection.select_all("SELECT * FROM table_name")
Følg linket for at forstå, hvordan du gemmer konfigurationsdetaljerne i database.yml:http://weare.buildingsky.net/2006/12/06/multiple-concurrent-database-connections-with-activerecord