Configure Ruby on Rails in OS x to access the SQL Server database.

Source: Internet
Author: User
Tags ruby on rails
ArticleDirectory
    • Step 1: Install freetds
    • Step 2: Install tiny_tds
    • Step 3: Install activerecord_sqlserver_adapter
    • Step 4: Modify the gemfile in the root directory of the ROR project and add the following two sentences:
    • Step 5: Run bundle install
    • Step 6: Modify database. yml
    • Finally, success

After a long time of hard work, Ror can finally access the SQL Server database in OS X. Record the operation process here so that you do not forget it later.

Step 1: Install freetds

Middleware and *. MSI), which only requires the first seven steps:

1. download the latest stable release  Freetds .
2. Extract freetds tgz file within downloads
3. Open terminal and CD to downloads/freetds-0. ** folder
4. Run "./configure"
5. Run "CP/usr/bin/glibtool libtool" <---- important!
6. Run "sudo make"
7. Run "sudo make install"

In this way, our freetds is installed.

Step 2: Install tiny_tds

Run: Gem install tiny_tds in the command line.

Don't ask me where the gem came from. Google the gem will find a lot of information. In OS X, GEM is built-in. Haha.

NOTE: If freetds is not installed, tiny_tds will certainly fail to be installed because it depends on freetds.

Step 3: Install activerecord_sqlserver_adapter

Similarly, you only need to execute: Gem install activerecord_sqlserver_adapter in the command line

Step 4: Modify the gemfile in the root directory of the ROR project and add the following two sentences:

Gem 'Tiny _ TDS'

Gem 'activerecord _ sqlserver_adapter'

Step 5: Run bundle install

Run bundle install in the command line. After running, many using statements will be output. Check whether tiny_tds and activerecord_sqlserver_adapter are included in the command line. This is correct only when they are included.

Step 6: Modify database. yml

Call the database. yml file under the root directory of the ROR project and under the config subdirectory, and modify the configuration as needed, for example:

Development:

Adapter: sqlserver

Mode: dblib

Dataserver: 10.4.30.77 \ sql2005 # name from freetds. conf, host or instance 'localhost \ sqlexpress'

HOST: 10.4.30.77 # used if dataserver is blank.

Port: 1433 # used if host present. Default is 1433.

Database: alo_db

Username: db_user

Password: xxxx

Timeout: 5000

Azure: false # For Windows azure

Finally, success

You can create a model: rails generate model myshipper shipperid: int shippername: String

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.