Connecting SQL Server and Rails 4.2.1

Hello friends,

I am new in Ruby on rails. I am using Rails 4.2.1 and Ruby 2.0.0. For some reason I am not able to connect my sql server to rails.

Can anyone help me regarding the database.yml file on connecting to sql server.

And is it the only file which I need to look into or are there any other files which needs to be modified.?

I tried to follow the instructions in some of the web forums suggesting to fix this, but I am getting an error when I give “rails console” command.

I am trying to create a model and I am not able to do this.

Please help me out

1) It looks like you have not installed a connection adapter for SQL Server. Rails does not automatically come with adapters for all databases. I don’t use it myself, but googling for "ruby on rails microsoft sql server” gets the adapter as the first hit, followed by a number of articles giving advice.

2) Once you have that installed, then yes, that single .yml file is the only one you need to modify.

3) In the future, please just copy and paste errors rather than sending us off to a website with a screen capture.

I probably should have qualified that statement—it’s the only thing directly related to Rails that you need to modify. But it’s still possible that you will have some issue with firewalls, networking, server config etc. Basically, once you can get any other tool on your box to connect to the server on that type of connection, then the only Rails-specific thing you need to do is setup .yml.

Can anyone help me regarding the database.yml file on connecting to sql server.

  1. It looks like you have not installed a connection adapter for SQL Server. Rails does not automatically come with adapters for all databases. I don’t > use it myself, but googling for "ruby on rails microsoft sql server” gets the adapter as the first hit, followed by a number of articles giving advice.

You need the ActiveRecord-SqlServer-Adapter: GitHub - rails-sqlserver/activerecord-sqlserver-adapter: SQL Server Adapter For Rails

and the TinyTDS gem: GitHub - rails-sqlserver/tiny_tds: TinyTDS - Simple and fast FreeTDS bindings for Ruby using DB-Library.