Настройка Rails для работы с sqlserver

Хорошо, я выполнил шаги по настройке ruby ​​и rails на моем компьютере с Vista, и у меня возникла проблема с подключением к базе данных.

Содержание database.yml

development:
  adapter: sqlserver
  database: APPS_SETUP
  Host: WindowsVT06\SQLEXPRESS
  Username: se
  Password: paswd

Запустите rake db:migrate из каталога myapp

----------
rake aborted!
no such file to load -- deprecated

ADO

У меня установлен dbi 0.4.0 и создана папка ADO в

C:\Ruby\lib\ruby\site_ruby\1.8\DBD\ADO

Я получил ado.rb от dbi 0.2.2

Что еще я должен посмотреть, чтобы решить проблему с подключением к базе данных? Пожалуйста, не говорите мне использовать MySql, Sqlite или Postgres.

****ОБНОВИТЬ****

Я установил гем activerecord-sqlserver-adapter с --source=http://gems.rubyonrails.org.

До сих пор не работает.

Я убедился, что могу подключиться к базе данных, войдя в SQL Management Studio с учетными данными.


рейк db:migrate --trace


PS C:\Inetpub\wwwroot\myapp> rake db:migrate --trace
(in C:/Inetpub/wwwroot/myapp)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
no such file to load -- deprecated
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:510:in `require'
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:355:in `new_constants_in'
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:510:in `require'
C:/Ruby/lib/ruby/site_ruby/1.8/dbi.rb:48
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:510:in `require'
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:355:in `new_constants_in'
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:510:in `require'
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/core_ext/kernel/requires.rb:7:in `require_library_
or_gem'
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnin
gs'
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/core_ext/kernel/requires.rb:5:in `require_library_
or_gem'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-1.0.0.9250/lib/active_record/connection_adapters/sqlserver
_adapter.rb:29:in `sqlserver_connection'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/connection_adapters/abstract/connection_specificatio
n.rb:292:in `send'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/connection_adapters/abstract/connection_specificatio
n.rb:292:in `connection='
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/connection_adapters/abstract/connection_specificatio
n.rb:260:in `retrieve_connection'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/connection_adapters/abstract/connection_specificatio
n.rb:78:in `connection'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/migration.rb:408:in `initialize'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/migration.rb:373:in `new'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/migration.rb:373:in `up'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/migration.rb:356:in `migrate'
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.1.1/lib/tasks/databases.rake:99
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:621:in `call'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:621:in `execute'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:616:in `each'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:616:in `execute'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:582:in `invoke_with_call_chain'
C:/Ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:575:in `invoke_with_call_chain'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:568:in `invoke'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:2031:in `invoke_task'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:2009:in `top_level'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:2009:in `each'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:2009:in `top_level'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:2048:in `standard_exception_handling'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:2003:in `top_level'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:1982:in `run'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:2048:in `standard_exception_handling'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:1979:in `run'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.2/bin/rake:31
C:/Ruby/bin/rake:19:in `load'
C:/Ruby/bin/rake:19
PS C:\Inetpub\wwwroot\myapp>

person FortunateDuke    schedule 24.09.2008    source источник


Ответы (6)


Я столкнулся с той же проблемой вчера. По-видимому, «deprecated» — это гем, поэтому вы хотите запустить «gem install deprecated», чтобы получить и установить последнюю версию. Удачи.

person djenryte    schedule 30.09.2008

Я использовал источник данных ODBC и адаптер SQL Server на Windows Server 2008 против SQL Server 2000, работающего на удаленном экземпляре.

Установить адаптер SQL Server

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

Создайте источник данных ODBC

  • Тип: SQL-сервер
  • Название: rails_development
  • Описание: rails_development
  • Сервер: СЕРВЕР
  • Аутентификация SQL (sa/12345)
  • База данных по умолчанию: БАЗА ДАННЫХ

Настроить базу данных.yml

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

YMMV

Пара полезных ссылок:

person John Naegle    schedule 30.12.2009

Вы установили адаптер SQL Server?

gem install activerecord-sqlserver-adapter --source=http://gems.rubyonrails.org
person hectorsq    schedule 25.09.2008

Если вы работаете на 64-битной машине, есть две программы администратора ODBC, одна для 32-битной и одна для 64-битной. activerecord-sqlserver-adapter ищет DSN, настроенные с 32-битной версией.

person Jarrod    schedule 06.11.2009

Правильная ссылка: http://rubyrailsandwindows.blogspot.com/2008/03/rails-2-and-sql-server-2008-on-windows_24.html

person minikermit    schedule 19.08.2010

Я тоже столкнулся с этой проблемой. Есть еще одна работа вокруг. Вы можете создать DSN для базы данных приложения из панели управления-> инструменты администратора-> Odbc. Файл Database.yml должен выглядеть следующим образом:

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

Я пытался использовать устаревший драгоценный камень, но это было бесполезно. Я также пытался установить адаптер ADO, который оказался бесполезным.

person Amol    schedule 12.08.2009