Guest User

Untitled

a guest
Jun 22nd, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. # This is an Example model file for connecting ActiveRecord to SQL Server 2005/2008
  2. # Make sure you have the following Gems installed on your system:
  3. # activerecord, activerecord-sqlserver-adapter, dbi, dbd-odbc
  4. # (Can also just run 'gem install activerecord dbi dbd-odbc activerecord-sqlserver-adapter')
  5.  
  6. ## Model.rb
  7.  
  8. require 'rubygems'
  9. require 'activerecord'
  10.  
  11. ActiveRecord::Base.establish_connection(
  12. :adapter => "sqlserver",
  13. :mode => "odbc",
  14. :dsn => 'Driver={SQL Server};Server=SERVER\\INSTANCE;Database=DB',
  15. :username => "USERNAME",
  16. :password => "PASSWORD"
  17. )
  18.  
  19.  
  20. class Model_Name < ActiveRecord::Base
  21. set_table_name "TABLE_NAME"
  22. set_primary_key "PRIMARY_KEY_COLUMN_NAME"
  23. end
Add Comment
Please, Sign In to add comment