Skip to content

Instantly share code, notes, and snippets.

@nikukyugamer
Last active May 24, 2018 07:43
Show Gist options
  • Select an option

  • Save nikukyugamer/7525193ad0ade6b228562bdac32fa81e to your computer and use it in GitHub Desktop.

Select an option

Save nikukyugamer/7525193ad0ade6b228562bdac32fa81e to your computer and use it in GitHub Desktop.
TODO after rails new

bundle exec rails...

$ bundle exec rails generate rspec:install
$ bundle exec rails generate sidekiq:worker Hard
$ bundle exec cap install
$ bundle exec rails webpack:install
$ bundle exec rails webpacker:install:vue
You need to enable unsafe-eval rule.
This can be done in Rails 5.2+ for development environment in the CSP initializer
config/initializers/content_security_policy.rb with a snippet like this:
if Rails.env.development?
  policy.script_src :self, :https, :unsafe_eval
else
  policy.script_src :self, :https
end
$ bundle exec rails generate simple_form:install

kaminari

  • ???

unicorn

better_errors allow_ip!

  • config/environments/development.rb
    • better_errors allow_ip!

config/application.rb

    config.generators do |g|
      g.assets false
      g.helper false
      g.test_framework :rspec,
                       fixtures: true,
                       view_specs: false,
                       helper_specs: false,
                       routing_specs: false,
                       controller_specs: true,
                       request_specs: false
      g.fixture_replacement :factory_bot, dir: 'spec/factories'
    end

Slim

  • config/application.rb
  class Application < Rails::Application
    # ...
    config.generators.template_engine = :slim
    # ...
  end

Timezone

  • config/application.rb
    config.time_zone = 'Tokyo'
    config.active_record.default_timezone = :local
    # config.i18n.available_locales = [:ja, :en] # i18n関連は必要になったらでいい

production assets valid when unicorn is app and web servers

  • config/environments/production.rb
  # Disable serving static files from the `/public` folder by default since
  # Apache or NGINX already handles this.
  # config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
  # https://qiita.com/y_minowa/items/5954907bb30c2ecb43f5
  # https://qiita.com/Yinaura/items/d7dc3daefb5825aba474
  config.public_file_server.enabled = true

yarn on development

To disable this check, please add `config.webpacker.check_yarn_integrity = false`
to your Rails development config file (config/environments/development.rb).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment