0
1

More than 3 years have passed since last update.

Rails開発する前にやっておくべきこと&便利なこと【備忘録】

Last updated at Posted at 2019-11-17

背景

新しいアプリを開発する際、毎回忘れるので備忘録として

rails new オプション

※以下sample_appsというアプリを作成する場合
$ rails _5.2.2_ new sample_apps
railsバージョン5.2.2で作成する
$ rails new sample_apps --database=使用するSQL名
SQLを指定し作成する
$ rails new sample_apps --skip-test
自動テスト機能を使用せず作成する
$ rails new sample_apps --skip-bundle
bundle install を初回実行せず作成する

Git

git initをしておきコミットしておく。

$ git init
$ git add .
$ git commit -m "init Rails Project"

データベース作成

rails db:create

ジェネレータの設定

ModelやControllerなどを作成する際、不要なものを自動生成しないため、下記のように設定する。

config/initializers/generators.rb
Rails.application.config.generators do |g|
  g.stylesheets false
  g.javascripts false
  g.helper false
  g.skip_routes true
end

ページネーション

※ページネーションを利用する場合
Gemfile
gem 'kaminari'
$ bundle install

$ rails g kaminari:views bootstrap4
ページネーションのデザイン調整

bootstrap4以外のデザインは、下記に多彩にありますのでお試しください。
https://github.com/amatsuda/kaminari_themes

以上

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