Railsでアプリ開発を始めるときの準備のまとめ

Rails new

$ rails _5.2.3_ new mapblog -d postgresql --skip-bundle

必要なGemのインストール

(Gemfile)

group :development, :test do
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'rspec-rails'
  gem 'factory_bot_rails'
  gem 'pry-rails'
end
group :test do
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'
  gem 'chromedriver-helper'
  gem 'webdrivers'
  gem 'launchy', '~> 2.4.3'
end
$ bundle

generatorsファイルの設定

$ touch config/initializers/generators.rb

(config/initializers/generators.rb)

Rails.application.config.generators do |g|
  g.assets false
  g.helper false
  g.test_framework :rspec,
    view_specs: false,
    helper_specs: false,
    routing_specs: false,
    controller_specs: false,
    request_specs: false
end

タイムゾーンの設定

(config/application.rb)

module Mapblog
  class Application < Rails::Application
    config.load_defaults 5.2

    config.time_zone = 'Tokyo'
    config.active_record.default_timezone = :local
  end
end

i18nで日本語化

$ touch config/initializers/locale.rb

(config/initializers/local.rb)

I18n.config.available_locales = [:en, :ja]
I18n.default_locale = :ja
$ touch config/locales/ja.yml

以下の内容をコピペ。

github.com