LoginSignup
1
2

More than 5 years have passed since last update.

《Rails》コントローラ作成時に不要なファイルを作成しない方法

Posted at

オプションを設定

rails g controller hoge
の後ろに下記のオプションをつける

オプション 生成されないファイル
--no-assets app/assets/stylesheets以下のcssファイル
app/assets/javascripts 以下のjsファイル
--no-helper app/helper以下のHelperファイル
--no-test-framework spec/controllers以下のSpecファイル
--skip-routes config/routes.rbのroutesの追記
--skip-template-engine app/views 以下のViewファイル

◾️参照
https://qiita.com/k_kibi/items/09f717f5a83d41b5f30a

config/application.rbに追記

require_relative 'boot'

require 'rails/all'

Bundler.require(*Rails.groups)

module hogehoge
  class Application < Rails::Application
    config.generators do |g|
      g.stylesheets false
      g.javascripts false
      g.helper false
      g.test_framework false
    end
  end
end
1
2
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
1
2