LoginSignup
5
1

More than 3 years have passed since last update.

Ruby on Rails簡易実装メモ

Last updated at Posted at 2020-07-12

Qiitaで記事を書く際にRailsで簡易実装をしたいときがある。
その際にコマンドを忘れてしまうのでメモ。随時必要なったら追記していく。

$ rails new [プロジェクト名] -d [データベース名]
$ cd [プロジェクト名]
$ rails db:create
$ rails generate scaffold [モデル名] [カラム名:型] [カラム名:型] [カラム名:型] ・・・

例えば、

$ rails new scaffold_app -d postgresql
$ cd scaffold_app/
$ rails db:create
$ rails generate scaffold user name:string nickname:string

slim化&binding.pryでデバックしたいとき

1、Gemfileに以下の記載

Gemfile
gem 'html2slim'
gem 'slim-rails'
gem 'pry-rails'

2、bundle installして、viewファイルをslim化--deleteオプションをつけるとerbのファイルは削除される。

console
$ bundle install
$ bundle exec erb2slim app/views/ --delete

すでにdbが存在している場合

rails db:migrate:reset

参考:https://kirohi.com/rails_duplicate_error

5
1
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
5
1