简体   繁体   中英

Connect rails to Sql Server

I am trying to connect Rails to Sql Server so I need to use an Sql Server adaptor. I installed it by downloading the adaptor locally from github.com/Desarrollo-CeSPI/activerecord-sqlserver-adapter.git. After that I did: gem build activerecord-sqlserver-adapter.gemspec in the directory where I had the spec file, followed by gem install <name of gem that was just built> . After that, I added this line in the gemfile: gem 'activerecord-sqlserver-adapter', :path => 'downloads/activerecord-sqlserver-adapter-master\\activerecord-sqlserver-adapter-master' , then I ran a bundle install from the project root.

The error is:

Bundler could not find compatible versions for gem "activerecord": In Gemfile: rails <=4.1.6> x86-mingw32 depends on activerecord <=4.1.6> x86-mingw32

activerecord-sqlserver-adapter <>=0> x86-mingw32 depends on activerecord <4.0.0>

What is strange is rails -v doesn't return the rails version although I just installed it. Instead it throws:

Could not find gem 'tzinfo-data <>=0> x86-mingw32 in the gems available on this machine
Run bundle install to install missing gems

I should specify we are compulsed to use proxies at work

Every few month I keep checking to see if the Sql Server connection is improved/easier to perform with Rails without adaptors and such, because I want to use Sql Server instead of PostgreSQL. No luck so far. Any help is much appreciated. Thanks

It looks like the gem that you are using only supports until rails 4.0.0 (the gemspec forces to be this version).

You might try to use that rails version to see what's going on.

To do so, in your Gemfile.rb you can try this:

gem 'rails', '4.0.0'
gem 'activerecord-sqlserver-adapter', git: ' https://github.com/Desarrollo-CeSPI/activerecord-sqlserver-adapter.git '

and then run

bundle update rails # to force using the rails version specified in the gemfile

and then run

bundle install

BUT

If you don't have anything to do with Desarrollo-CeSPI, then you should use the official gem to avoid some problems, for instance that the gem is not maintained anymore.

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