I’m trying to connct to an MSSQLserver 2008 on a WinXP box.
$ ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
$ rails --version
Rails 3.0.1
$ gem list --local
*** LOCAL GEMS ***
abstract (1.0.0)
actionmailer (3.0.1, 3.0.0)
actionpack (3.0.1, 3.0.0)
activemodel (3.0.1, 3.0.0)
activerecord (3.0.1)
activerecord-sqlserver-adapter (3.0.5)
activeresource (3.0.1, 3.0.0)
activesupport (3.0.1, 3.0.0, 1.4.4)
arel (2.0.2, 1.0.1)
builder (2.1.2)
bundler (1.0.3)
cgi_multipart_eof_fix (2.5.0)
dbi (0.4.5)
deprecated (3.0.0, 2.0.1)
erubis (2.6.6)
fastthread (1.0.1 i386-mswin32)
gem_plugin (0.2.3)
i18n (0.4.2, 0.4.1)
linecache (0.43 mswin32)
mail (2.2.9, 2.2.7)
mime-types (1.16)
mongrel (1.1.5 x86-mingw32)
mongrel_service (0.4.beta3)
mysql (2.8.1 x86-mingw32, 2.7.3 mswin32)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack-test (0.5.6)
rails (3.0.1)
railties (3.0.1, 3.0.0)
rake (0.8.7)
rdiscount (1.6.5)
ruby-debug-base (0.10.3 mswin32)
ruby-debug-ide (0.4.5)
ruby-odbc (0.99992)
sqlite3-ruby (1.3.2 x86-mingw32, 1.3.1 x86-mingw32)
thor (0.14.4, 0.14.3)
treetop (1.4.8)
tzinfo (0.3.23)
database.yml
development:
adapter: sqlserver
database: m_development
dsn: M2
mode: odbc
username: user
password: Secret
encoding: utf8
Every time I run rails generate scaffold Something, I get an error like
this one:
$ rails generate scaffold Test
invoke active_record
c:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:71:in
establish_connection': Please install the sqlserver adapter:gem install activerecord-sqlserver-adapter(no such file to load -- active_record/connection_adapters/sqlserver_adapter) (RuntimeError) from c:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:60:inestablish_connection’
from
c:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in
`establish_connection’
If I look in connection_specification.rb around line 71 I see this:
begin
require
“active_record/connection_adapters/#{spec[:adapter]}_adapter”
rescue LoadError
raise “Please install the #{spec[:adapter]} adapter: gem install activerecord-#{spec[:adapter]}-adapter (#{$!})”
end
Some debugging tells me that spec[:adapter] contains the “sqlserver”
from the database.yml file. But I have, as you can see from the list of
installed gems, already installed the SQLServer Adapter, so why can’t it
be found?
I have tried to run gem install activerecord-sqlserver-adapter more than
once, but that doesn’t help, and I can find the gem in WindowsExplorer
in
“C:\Ruby\lib\ruby\gems\1.8\gems\activerecord-sqlserver-adapter-3.0.5\lib\active_record\connection_adapters”
Is it a problem with GEM_HOME or do I use a wrong version of rails?
Thanks
Magnus
