What is ActiveRecord?
- ActiveRecord is a Ruby library that was written by the creators of Ruby on Rails to do database integration. It connects classes to relational database tables to establish an almost zero-configuration persistence layer for applications.
That’s great, but we’re not using Ruby on Rails and our web app has SQL Server on the back end. How can we leverage ActiveRecord in our environment?
- Good news! You can use ActiveRecord without Rails! If you are a Ruby programmer, you can can connect very easily to SQL Server to create models! You get a great deal of functionality such as basic CRUD operations, data validations, search support and many others!
- All of this can be accomplished with the activerecord-sqlserver-adapter gem.
How do I connect ActiveRecord to SQL Server?
- Install the Ruby Development Kit (http://wiki.github.com/oneclick/rubyinstaller/development-kit
- Be sure to follow the steps here to install the dev kit (https://github.com/oneclick/rubyinstaller/wiki/development-kit)
- gem install ruby-odbc
- gem install activerecord-sqlserver-adapter
- Create system ODBC Data Sources for each environment (http://msdn.microsoft.com/en-us/library/ms714024(VS.85).aspx)
For more information, check out my example: