Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This is an Example model file for connecting ActiveRecord to SQL Server 2005/2008
- # Make sure you have the following Gems installed on your system:
- # activerecord, activerecord-sqlserver-adapter, dbi, dbd-odbc
- # (Can also just run 'gem install activerecord dbi dbd-odbc activerecord-sqlserver-adapter')
- ## Model.rb
- require 'rubygems'
- require 'activerecord'
- ActiveRecord::Base.establish_connection(
- :adapter => "sqlserver",
- :mode => "odbc",
- :dsn => 'Driver={SQL Server};Server=SERVER\\INSTANCE;Database=DB',
- :username => "USERNAME",
- :password => "PASSWORD"
- )
- class Model_Name < ActiveRecord::Base
- set_table_name "TABLE_NAME"
- set_primary_key "PRIMARY_KEY_COLUMN_NAME"
- end
Add Comment
Please, Sign In to add comment