简体   繁体   中英

Error using activerecord-sqlserver-adapter

I installed activerecord-sqlserver-adapter such that it appears in my local gems. Running the command...

rails generate scaffold Tablename fieldname:fieldtype

returns an error (as below). I've rails 1.9.2 installed. Any guidance or assistance would be much appreciated. Thanks

C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-.2.8/lib/active_support/dependencies.rb:251:in `require': Please install the sqlserver adapter: `gem install activerecord-sqlserver-adapter` (no such file to load -- active_record/connection_adapters/sqlserver_adapter) (LoadError)
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-.2.8/lib/active_support/dependencies.rb:251:in `block in require'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-.2.8/lib/active_support/dependencies.rb:251:in `require'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:50:in `resolve_hash_connection'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:129:in `establish_connection'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-.2.8/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-.2.8/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-.2.8/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-.2.8/lib/active_support/lazy_load_hooks.rb:42:in `each'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/base.rb:721:in `<top (required)>'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/generators/named_base.rb:166:in `pluralize_table_names?'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/generators/named_base.rb:114:in `table_name'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/rails/generators/active_record/model/model_generator.rb:17:in `create_migration_file'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/task.rb:27:in `run'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/invocation.rb:120:in `invoke_task'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `block in invoke_all'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `each'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `map'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `invoke_all'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/group.rb:238:in `dispatch'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/invocation.rb:109:in `invoke'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/group.rb:281:in `block in _invoke_for_class_method'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/shell.rb:74:in `with_padding'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/group.rb:270:in `_invoke_for_class_method'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/group.rb:150:in `_invoke_from_option_orm'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/task.rb:27:in `run'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/invocation.rb:120:in `invoke_task'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `block in invoke_all'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `each'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `map'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `invoke_all'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/group.rb:238:in `dispatch'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/base.rb:425:in `start'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/generators.rb:171:in `invoke'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-.2.8/lib/rails/commands/generate.rb:12:in `<top (required)>'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-.2.8/lib/active_support/dependencies.rb:251:in `require'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-.2.8/lib/active_support/dependencies.rb:251:in `block in require'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-.2.8/lib/active_support/dependencies.rb:251:in `require'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:29:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

* LOCAL GEMS *

actionmailer (3.2.8, 3.1.0, 2.2.3)
actionpack (3.2.8, 3.1.0, 2.2.3)
activemodel (3.2.9, 3.2.8, 3.1.0)
activerecord (3.2.8, 3.1.0)
activerecord-sqlserver-adapter (3.2.10, 3.1.7)
activeresource (3.2.8, 3.1.0)
activesupport (3.2.9, 3.2.8, 3.1.0, 2.2.3)
ansi (1.4.3, 1.3.0)
archive-tar-minitar (0.5.2)
arel (3.0.2, 2.2.1)
bcrypt-ruby (3.0.1 x86-mingw32)
builder (3.0.4, 3.0.0)
bundler (1.2.1)
coffee-rails (3.2.2, 3.1.1)
coffee-script (2.2.0)
coffee-script-source (1.4.0, 1.1.2)
columnize (0.3.6)
erubis (2.7.0)
execjs (1.4.0, 1.2.9)
ffi (1.1.5)
hike (1.2.1)
i18n (0.6.1, 0.6.0)
journey (1.0.4)
jquery-rails (2.1.4, 2.1.3, 1.0.14)
json (1.7.5, 1.6.1)
linecache19 (0.5.12)
mail (2.4.4, 2.3.0)
mime-types (1.19, 1.16)
minitest (4.1.0, 3.5.0, 3.4.0, 1.6.0)
multi_json (1.4.0, 1.3.7, 1.3.6, 1.0.3)
nokogiri (1.5.5 x86-mingw32)
polyglot (0.3.3, 0.3.2)
rack (1.4.1, 1.3.4)
rack-cache (1.2, 1.0.3)
rack-mount (0.8.3)
rack-ssl (1.3.2)
rack-test (0.6.2, 0.6.1)
rails (3.2.8, 3.1.0)
railties (3.2.8, 3.1.0)
rake (10.0.2, 10.0.1, 0.9.2.2, 0.9.2, 0.8.7)
rdiscount (1.6.8)
rdoc (3.12, 3.10, 2.5.8)
ruby-debug-base19 (0.11.25)
ruby-debug-ide (0.4.16)
ruby-debug19 (0.11.6)
ruby_core_source (0.1.5)
sass (3.2.3, 3.1.10)
sass-rails (3.2.5, 3.1.4)
sprockets (2.1.3, 2.0.2)
sqlite3 (1.3.6 x86-mingw32, 1.3.4 x86-mingw32)
sqlite3-ruby (1.3.3)
thor (0.16.0, 0.14.6)
tilt (1.3.3)
tiny_tds (0.5.1 x86-mingw32)
tmail (1.2.7.1)
treetop (1.4.12, 1.4.11, 1.4.10)
turn (0.9.6, 0.8.3)
tzinfo (0.3.35, 0.3.30)
uglifier (1.3.0, 1.0.3)
win32-sound (0.5.0)

Is the gem listed in your Gemfile ?

Add to your gemfile ( gem manual )

gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter', '~> 3.1.0'

and run bundle install again

Finally resolved this. To fix I uninstalled 2 conflicting versions of activerecord-sqlserver-adapter, installed ruby-odbc gem, installed activerecord-sqlserver-adapter, tweaked the gemfile to reflect correct versions then ran bundle update, then bundle install and lastly the rails generate scaffold... command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM