LoginSignup
3

More than 5 years have passed since last update.

Rails5.0 基本事項まとめ 〜①よく使うコマンド編〜

Posted at

概要

ターミナルでRailsを操作する時によく使うコマンド一覧です。

Rails-Command

新規アプリケーションの作成

$ rails new <appName>

MySQL Ver.

$ rails new <appName> -d mysql

サーバ起動

$ rails s(erver)

マイグレーションスクリプトを実行

$ rails db:migrate

雛型ファイルの作成

Migration

$ rails g migration AddAuthorToBooks author:string

カラム名と型の間にはスペースを開けない事。

Model + Migration

$ rails g model book title:stirng memo:text

Routes + Controller + View

$ rails g controller books index

Scaffold = Model + Migration + Routes + Controller + View

$ rails g scaffold book title:string memo:text

railsリソースの削除

$ rails d(estroy) <Resource>

1行ずつコードを実行

$ rails c(onsole)

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
3