Edited at

Rails4 で Oracle を使い始める

More than 5 years have passed since last update.

環境

- Rails 4.0.4

- ruby-oci8 (2.1.7)

- activerecord-oracle_enhanced-adapter (1.5.4)

前提

- sqlplus system/oracle@127.0.0.1/xe で接続できる

サンプル

- https://github.com/usutani/blog_with_oracle_enhanced-adapter

-

alias g='git'

alias be='bundle exec'

rails _4.0.4_ new blog --skip-bundle

cd blog

vi Gemfile

gem 'ruby-oci8', '~> 2.1.0'

gem "activerecord-oracle_enhanced-adapter", "~> 1.5.0"

bundle install --path vendor/bundler

vi config/database.yml

development:

adapter: oracle_enhanced
database: //127.0.0.1:1521/xe
username: blog_development
password: oracle

$ be rake db:create

Please provide the SYSTEM password for your Oracle installation
> oracle

be rake db:migrate:status

be rake db:migrate

sqlplus blog_development/oracle@127.0.0.1/xe

SQL> select * from tab;

SQL> desc schema_migrations

rails g scaffold Post title body:text

be rake db:migrate

rails s

-

ユーザーの削除

sqlplus system/oracle@127.0.0.1/xe

SQL> select username from all_users;

SQL> drop user USER cascade;