Rails 3, Ruby 1.9.2, Windows 2008, and SQL Server 2008 Tutorial
This took me a while to figure out, especially since I’m not so great with either windows or SQL server, but in the end the process isn’t so difficult.
Rails 3, Ruby 1.9.2, Windows 2008, and SQL Server 2008 Screencast
The steps covered in this screencast are:
- Create user
- Create database
- Give user permissions
- Create DSN
- Install ruby
- Install devkit (Needed to complie native extensions for ODBC)
- Create a new rails app
- Add
activerecord-sqlserver-adapterandruby-odbcto Gemfile - Customize
config/database.yml
1 2 3 4 5 6 7 8 |
# config/database.yml development: adapter: sqlserver dsn: testdsn_user mode: odbc database: test username: xavier password: |
Some errors you may encounter:
The specified module could not be found – odbc.so You have likely copied odbc.so from i386-msvcrt-ruby-odbc.zip. This is for 1.8.7, and does not work for 1.9. Remove the .so file, and install ruby-odbc as above.
The specified DSN contains an architecture mismatch between the Driver and the Application. Perhaps you have created a system DSN. Try creating a user DSN instead. I also found some suggestions that you need to use a different version of the ODBC configuration panel, but this wasn’t relevant for me.
October 10, 2010 at 8:11 AM
that's one blazin' fast win 2008 server!
October 12, 2010 at 6:09 AM
That's what happens when you run it on a MacBook Pro ;)
(or you know, edit out the slow bits...)
October 13, 2010 at 7:16 AM
Checkout ironruby and the adonet mode instead, much faster and easier than odbc.. http://github.com/rails-sqlserver/activerecord-sqlserver-adapter
http://ironruby.net/
October 13, 2010 at 9:44 AM
Carl, I've been hearing that IronRuby is pretty much dead. I'm going down the JRuby path (probably will switch to JDBC drivers then, I imagine). Do you have evidence contrary? Are you running Rails on IronRuby in production?
October 13, 2010 at 1:41 PM
I always love sharing good info! I added your article as a link from the adapter's wiki page here http://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Platform-Installation---Windows
October 13, 2010 at 2:16 PM
Xavier, I assume you're still using webrick for development, but how are you hosting in production? Are you using IIS?
October 13, 2010 at 2:48 PM
+1 for Eddie's question. Figuring out a way to get IIS to serve Rails is my Everest (I have failed billions of times).
I tried it with IronRuby, but it was not easy and I never completely got it working. Also heard that IronRuby is dead, with 2 of the main IronRuby doods leaving Microsoft.
If you can get a somewhat easy-to-deploy IIS solution going, I will sing your praises from the mountaintops. Or something.
Great post,
Ruprict
October 19, 2010 at 1:45 AM
Not in production yet, pretty sure I'm going to use jRuby with glassfish. There will definitely be a post about that!
December 08, 2010 at 5:24 PM
Thanks, really helped me out.
December 16, 2010 at 3:50 PM
I'm making a new production 2008 r2 server and i've figured out that iis7 could manage rails in fastcgi:
http://blogs.iis.net/ruslany/archive/2008/08/07/ruby-on-rails-in-iis-7-0-with-url-rewriter.aspx
January 26, 2011 at 6:33 PM
Have you tried connecting to SQL Azure using the above setup? (ie Rails 3, Ruby 1.9.2, Windows 2008, and SQL Server 2008 and also i'm using activerecord-sqlserver-adapter 3.0.9 found here https://github.com/rails-sqlserver/activerecord-sqlserver-adapter).
After some searching I found:
http://blogs.msdn.com/b/mcsuksoldev/archive/2010/02/26/9969876.aspx
but it doesn't seem to work with the above setup.
January 28, 2011 at 3:16 AM
I haven't tried, and no longer have the setup to try. Let us know if you win.
April 19, 2011 at 12:36 PM
This was a much needed video, thank you so much for putting this out for all to learn from!
July 08, 2011 at 11:48 AM
Hey guys,
Just to add for production this looks like it'll work nicely:
http://www.helicontech.com/articles/run-django-apps-on-iis/
Bear in mind it will install Ruby as part of the install, and you need to bundle install before running the app. Nice easy setup though.
In the BlankRubyOnRails project folder there is a web_config.xml file that you can copy to any of your other apps. Just change the port to 80 in the settings if you wanted to use it in production.
Kind Regards
Luke
December 28, 2011 at 11:42 PM
Amazing! This post finally helps me after googlin' for hours :)
December 28, 2011 at 11:45 PM
Can I link to your post in my own blog? (just to spread this good tutorial)
December 31, 2011 at 2:11 AM
Don't need to ask permission to link :)
January 12, 2012 at 3:49 PM
Hi Xavier,
Thanks for this great article. I have followed every step but I am stuck on the part where I need to create DSN. Specifically the dialog where I select "With SQL Server authentication using a login ID ...". The checkbox "Connect to SQL Server to obtain default settings ..." is checked. Login ID: is "jett" which I just created and set permissions as you described. But when I click Next I get the error below:
Microsoft SQL Server Login
Connection failed:
SQL State: '28000'
SQL Server Error: 18456
[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'jett'
I am using SQL Server Express 2008 R2. I get similar error when I try connecting manually in SQL Server Management Studio to .\SQLEXPRESS server using the same login account (jett).
Any help will be greatly appreciated.
Thanks,
Jett
January 18, 2012 at 9:37 PM
@jett, whats up with the password`?
January 23, 2012 at 3:50 PM
@ beast, I didn't use any password as described in the tutorial. I did exactly same thing in the tutorial. I even tried doing the steps to the letter. I created user xavier with no password, testdb and mydsn.. Still didn't work.
I also tried using C:\Windows\SysWOW64\odbcad32.exe to create the DSN didn't do the trick.
I use SQL Server Express 2008 R2 on Windows 7 64 bit.
January 24, 2012 at 3:22 PM
Never mind guys. I fixed my issue by uninstalling and reinstalling SQL Server Express.