2007年5月10日 星期四

Connect DB by ODBC on Rails

  1. Install
    rails 1.2 gem install -v=1.4 odbc-rails
    rails 1.1 gem install -v=1.3 odbc-rails

  2. Enabling Loading of the Adapter
    -> root\lib\ruby\gems\1.8\gems\activerecord-1.14.4\lib\active_record
         RAILS_CONNECTION_ADAPTERS = %w( mysql postgresql ... openbase odbc)

  3. Set up your Ap
    your ap -> config/environment.rb
                         require File.join(File.dirname(__FILE__), 'boot')
                         require 'odbc_adapter'
    -> config/database.yml
                         development:
                         adapter: odbc
                         dsn: 使用者資料來源名稱
                         username:
                         password:
                         host: localhost
                         encoding: utf8

沒有留言: