Setting up Rails to work with sqlserver

后端 未结 6 1602
孤城傲影
孤城傲影 2020-12-31 08:15

Ok I followed the steps for setting up ruby and rails on my Vista machine and I am having a problem connecting to the database.

Contents of database.yml

相关标签:
6条回答
  • 2020-12-31 08:35

    Correct link is http://rubyrailsandwindows.blogspot.com/2008/03/rails-2-and-sql-server-2008-on-windows_24.html

    0 讨论(0)
  • 2020-12-31 08:38

    I used and ODBC data source and the SQL Server adapter on Windows Server 2008 against SQL Server 2000 running on a remote instance.

    Install SQL Server Adapter

    gem.bat install activerecord-sqlserver-adapter
      Successfully installed deprecated-2.0.1
      Successfully installed dbi-0.4.1
      Successfully installed dbd-odbc-0.2.4
      Successfully installed activerecord-sqlserver-adapter-2.2.22
      4 gems installed
    

    Create an ODBC datasource

    • Type: SQL Server
    • Name: rails_development
    • Description: rails_development
    • Server: SERVER
    • SQL Authentication (sa/12345)
    • Default Database: DATABASE

    Setup database.yml

    development:
        adapter: sqlserver
        mode: odbc
        dsn: rails_development
        username: sa
        password: 12345
    

    YMMV

    A couple of helpful links:

    • http://rubyrailsandwindows.blogspot.com/2008/03/rails-2-and-sql-server-2008-on-windows_24.html
    • http://wiki.rubyonrails.org/rails/pages/HowToUseLegacySchemas
    0 讨论(0)
  • 2020-12-31 08:40

    I too had faced this problem. There is another work around. You can create a DSN for the app db from control panel->admin tools->Odbc. Database.yml file should look like below:

    adapter: sqlserver
    mode: odbc
    dsn: DSN_NAME
    host: localhost
    database: App_development
    username: uname
    password: password
    

    I tried using the deprecated gem, wasn't of much use. I had tried installing an ADO adaptor too which rendered useless.

    0 讨论(0)
  • 2020-12-31 08:44

    Did you install the SQL Server adapter?

    gem install activerecord-sqlserver-adapter --source=http://gems.rubyonrails.org
    
    0 讨论(0)
  • 2020-12-31 08:44

    If you're on a 64 bit machine, there are two ODBC administrator programs, one for 32 bit and one for 64 bit. activerecord-sqlserver-adapter looks for DSNs set up with the 32 bit version.

    0 讨论(0)
  • 2020-12-31 08:54

    I ran into the same problem yesterday. Apparently 'deprecated' is a gem, so you want to run "gem install deprecated" to grab and install the latest version. Good luck.

    0 讨论(0)
提交回复
热议问题