LoginSignup
15
16

More than 5 years have passed since last update.

Rails4 で Oracle を使い始める

Last updated at Posted at 2014-04-16

環境
- 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;

15
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
16