How To: Rails with SQL Server 2008
November 1, 2009
Most common database used with Rails is mySQL but if you ever need to use SQL Server, here is a quick how to.
I am using Windows Vista, SQL Server 2008, Rails 2.2.
1) Install activerecord-sqlserver-adapter gem
> gem install activerecord-sqlserver-adapter
2) Create a new Login for this new database (say testuser) using SQL Server Management Studio
3) Create a new database in SQL Server 2008 for your project (say testproject) and choose testuser as Owner
4) Create a new ODBC DNS
Control Panel -> Administrative Tools -> Data Sources (ODBC)
Add a new ‘User DSN’, choose SQL Server, give a name for DSN (say testprojectconn) then configure SQL Server authentication.
5) Now create your rails application as usual. Configure db connection using database.yml as follows
adapter: sqlserver
mode: odbc
dsn: testprojectconn
host: localhost
username: testuser
password: testpass
encoding: utf8
Thats it!



November 12, 2009 at 12:49 pm
[...] dati (ad esempio testuser) utilizzando SQL Server Management Studio 3) Creare un nuovo [...] From: N Rao Lakkakula’s Blog. Continue reading. Categorie:Senza categoria Tag: Commenti (0) Trackbacks (0) Lascia un [...]
September 3, 2010 at 12:18 am
thank you~