Unable to connect sql server using ruby on rails
You installed version 2.3.8
of the activerecord-sqlserver-adapter
gem that is almost 8 years old and tried to run it with the latest version of Ruby on Rails. Obviously, both versions are not compatible.
Furthermore, looking at the gem's Rubygem page - there is no version supporting Ruby on Rails 5.2 yet.
My advice is to downgrade your application to 5.1 and postpone updating to Rails 5.2 until all gems your application is depending on are supporting 5.2
You might want to subscript to these issues on GitHub for further updates:
- https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues/636
- https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues/647
How may i connect ruby on rails with sql server on windows
Sorry to disappoint you, but there are no easy solutions for using Rails on a Windows platform. It was not designed to run on Windows and I don't think I would recommend Windows as a platform for a Rails app. Not to say it hasn't been done, but in my experience it would be far easier to setup and run on a Linux platform as it was designed to do.
There is support for MS SQL server and Rails and you can checkout this project for more information.
My recommendation is to learn more about Rails and setting it up the environment, because a red flag to me is that you want to deploy a Rails app and yet do not know how to set it for production. This should be Rails 101 knowledge. Production is just another environment for Rails, there are things you need to be aware of when running a Rails app in production and this information can be found on easily rubyonrails.org.
Put some more time into learning Rails and perhaps setup a Linux virtual machine, deploy your Rails app, and experiment. Once you learn how to deploy Rails on a Linux platform them perhaps it may be a little easier to understand how to go about doing it on Windows.
please refer :-- https://github.com/rails-sqlserver/activerecord-sqlserver-adapter
Or else you can try with this
What is left is to learn is how to use database engine that is probably of the most interest for developers who work on Windows – Microsoft's SQL Server. If you do not have MS SQL Server installed go ahead and download MS SQL Server Express installer from Microsoft's site. I will use version 2014 in this book. Let's first create database that we will use in our Rails application:
osql -b -S localhost -U -P -Q "CREATE DATABASE RwinBookDevel COLLATE SQL_Latin1_General_CP1_CS_AS"
Newest rails adapter for MS SQL Server uses tiny_tds library to connect to MS SQL server and its usage is almost straigtforward. First thing we have to do is to add following two lines to Gemfile:
gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter'
And run bundle install
.
With all prerequisites met we can now configure our Ruby on Rails application to use SQL Server. Connection options are displayed below:
development:
adapter: sqlserver
mode: dblib
host: localhost
port: 1433
username: <your_db_user_name>
password: <your_db_password>
database: ABC
Hope this will help you......
Connect Sql server in Ruby on rails
I haven't done it on Windows, but if it's anything like connecting to postgresql on a mac you have to:
- Have sql-server running locally (http://msdn.microsoft.com/en-us/library/ms143219.aspx ?)
- Add a gem to your gemfile that will allow Rails to talk to
sql-server, probably this:
https://github.com/rails-sqlserver/activerecord-sqlserver-adapter |gem 'activerecord-sqlserver-adapter', '~> 3.1.0'
- Update your database.yml file for sql server, example here: Setting up Rails to work with sqlserver (plus it's also the answer)
- Then you would just create the db and migrate it. On a mac it's like
thisrake db:create && rake db:migrate
How to connect Ruby to SQL Server Management Studio?
try a dlib connection
with the activerecord-sqlserver-adapter
gem:
development:
adapter: sqlserver
mode: dblib
database: sqlserverdatabase
host: host
port: port
username: username
password: password
Connecting to an MSSQL database from a Ruby on Rails application running on Ubuntu
This Stackoverflow question might help: Rails & MSSQL 2008 - Will We Hit Barriers?
Basically you will need to install a MSSQL database adapter (rather than MySQL or Postgres that most tutorials step you through), and configure your database.yml appropriately:
http://rorblog.techcfl.com/2008/04/14/ruby-on-rails-connection-to-sql-server/
http://the-banana-peel.saltybanana.com/2008/06/connecto-to-microsoft-sql-server-from.html
http://wiki.rubyonrails.org/database-support/ms-sql (Although the rails wiki looks down at time of writing)
P.S. I am assuming the MSSQL server will be running on a separate Microsoft server someplace.
in rails 5 can I connect Microsoft sql server 2008?
In the very beginning I was thinking that your problem was related to the availability of the gem for your current ruby version (something like this issue on GitHub).
Digging into the documentation of the gem, in order to install on win you should run rake gem:windows
first:
Compiling Gems for Windows
For the convenience of Windows users, TinyTDS ships pre-compiled gems
for Ruby 2.0, 2.1, 2.2, and 2.3 on Windows. In order to generate these
gems, rake-compiler-dock is used. This project provides a Docker image
with rvm, cross-compilers and a number of different target versions of
Ruby.Run the following rake task to compile the gems for Windows. This will
check the availability of Docker (and boot2docker on Windows or OS-X)
and will give some advice for download and installation. When docker
is running, it will download the docker image (once-only) and start
the build:
$ rake gem:windows
Related Topics
Group by and Count Using Activerecord
SQL Combine Two Columns in Select Statement
Store and Reuse Value Returned by Insert ... Returning
How to Determine If a String Is Numeric in SQL
Return a Query from a Function
How to Build a Summary by Joining to a Single Table with SQL Server
Copy a Table (Including Indexes) in Postgres
How Does Mongodb Avoid the SQL Injection Mess
Mysql: How to Determine Foreign Key Relationships Programmatically
How to Use Update Trigger to Update Another Table
How to Do "Where Exists" in Arel
Query Several Nextval from Sequence in One Statement
Postgresql Selecting Most Recent Entry for a Given Id
How to Pivot Dynamically with Date as Column
When to Open and Close Brackets Surrounding Joins in Ms Access SQL
How to Get Value Using Join Table with Different Values