shimgo
8/12/2019 - 2:59 PM

railsのコードリーディング

# railsのソースを取得
git clone https://github.com/rails/rails.git

# PostgreSQLのインストール
# bundle installで怒られるので先にインストールしておく(MySQLが入ったマシン
で試したのでMySQLもいるかも)
brew install postgresql

bundle install

# コードリーディングに使うテストプロジェクトを作成
bundle exec rails new ../CodeReading --dev

cd ../CodeReading
# Gemfileに下記gemを追加
# gem 'pry-rails'
# gem 'pry-doc'
# gem 'pry-byebug'
# gem 'byebug'
# gem 'rb-readline'

bundle install

# 下記のようなカーディナリティのモデルを作成
# orders *--* products 1--* tags
# orders *--1 clients
# orders 1--1 invoices
rails g model client name:string
rails g model product name:string
rails g model invoice amount:integer
rails g model tag name:string product:references
rails g model order note:string client:references invoice:references
rails g model order_detail quantity:integer order:references product:references