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