Skip to content

Instantly share code, notes, and snippets.

@runeleaf
Last active December 14, 2015 21:19
Show Gist options
  • Save runeleaf/5149975 to your computer and use it in GitHub Desktop.
Save runeleaf/5149975 to your computer and use it in GitHub Desktop.
osx10.8 (centos6.3)
rails 4.0.0.beta1
windows7
sql server 2008 R2 Express
== windowsの設定
SQL Server 2008 R2 Express のインストール
http://awoni.net/fc/2008-r2
データベースおよびアカウントの作成
http://awoni.net/fc/vista-sql-server-settings/
sqlサーバのSQL Server認証をONにする
http://msdn.microsoft.com/ja-jp/library/ms188670(v=sql.90).aspx
→セキュリティ認証モードを変更するには
→Management Studioを使用してsaログインを有効にするには
ファイアーウォールに1433ポート追加
SQL Server をリモート接続-ファイアウォールの設定
http://awoni.net/tips/firewall-sql-server/
== linuxにfreetdsインストール
$ yum install unixODBC unixODBC-devel
$ wget ftp://ftp.astron.com/pub/freetds/stable/freetds-stable.tgz
$ tar zxvf freetds-stable.tgz
$ cd freetds-0.91
$ ./configure
$ make && make install
== osxにfreetdsインストール
> brew install unixodbc
> brew install freetds
> brew install ruby-odbc
-- freetdsが入らないようであれば
> sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
> brew install mpfr -use-gcc
> brew tap homebrew/versions
> brew install gcc45
> brew install freetds
-- それでもfreetdsが入らない!
> cp /Library/Caches/Homebrew/freetds-0.91.tar.gz /usr/local/src/
> cd /usr/local/src
> tar zxvf freetds-0.91.tar.gz
> cd freetds-0.91
> ./configure --prefix=/usr/local/Cellar/freetds/0.91 --with-openssl=/usr/local/bin --with-tdsver=7.1 --mandir=/usr/local/Cellar/freetds/0.91/share/man --with-unixodbc=/usr/local/
> make && make install
> brew link freetds
== 設定ファイル
/usr/local/etc/freetds.conf
[mssql]
host = 192.168.0.92
instance = SQLEXPRESS
port = 1433
tds version = 8.0
== 接続のチェック
> tsql -S mssql -U usernam
Password:
locale is "ja_JP.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1>
== railsの設定
vim Gemfile
source 'https://rubygems.org'
gem 'rails', '4.0.0.beta1'
gem 'activerecord-sqlserver-adapter', git: 'https://github.com/runeleaf/activerecord-sqlserver-adapter'
gem 'tiny_tds', git: 'https://github.com/runeleaf/tiny_tds'
gem 'activerecord-session_store'
# gem 'railstar', '0.0.12'
group :assets do
gem 'sass-rails', '~> 4.0.0.beta1'
gem 'coffee-rails', '~> 4.0.0.beta1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'jbuilder', '~> 1.0.1'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
gem 'capistrano', group: :development
# To use debugger
# gem 'debugger'
group :development do
gem 'better_errors'
gem 'binding_of_caller'
gem 'meta_request'
end
group :test do
gem 'spring'
gem 'rspec-rails'
gem 'cucumber-rails', '~> 1.0', require: false
gem 'database_cleaner'
gem 'guard'
gem 'guard-rspec'
gem 'guard-cucumber'
gem 'spork', '~> 0.9.0.rc'
gem 'guard-spork'
gem 'rb-fsevent', require: false
gem 'capybara'
gem 'factory_girl_rails'
end
vi config/database.yml
development:
adapter: sqlserver
encoding: utf8
reconnect: false
host: '192.168.0.92'
port: 1433
database: database_name
username: user_name
password:
timeout: 25
#dataserver: mssql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment