---
title: Reduce Application Clutter, Disable Unwanted Rails Generators
teaser:
tags: web,rails
author: Harlow Ward
published_on: 2012-10-24
---

![Disable rails generators](http://imageshack.us/a/img213/204/clutterrails.png)

Rails has some handy generators to help streamline the creation of models, views, controllers, and a bunch of other goodies.

    ~/dev/kitten_factory $ rails g controller Kittens
      create  app/controllers/kittens_controller.rb
      invoke  erb
      create    app/views/kittens
      invoke  helper
      create    app/helpers/kittens_helper.rb
      invoke  assets
      invoke    coffee
      create      app/assets/javascripts/kittens.js.coffee
      invoke    scss
      create      app/assets/stylesheets/kittens.css.scss

Unfortunately, over time the unused files that are created (and not deleted) add clutter to your application.

    ~/dev/kitten_factory $ wc -l app/helpers/*
           2 app/helpers/allergies_helper.rb
          14 app/helpers/application_helper.rb
           2 app/helpers/invitations_helper.rb
           # lots of unused helper files
           # ...
           2 app/helpers/trainers_helper.rb
           2 app/helpers/vets_helper.rb
         194 total # 178 lines of unused application code

Luckily with a small adjustment to your application environment we can avoid the generation of unnecessary files.

```ruby
# config/application.rb
module KittenFactory
  class Application < Rails::Application
    # Disable generation of helpers, javascripts, css, and view specs
    config.generators do |generate|
      generate.helper false
      generate.assets false
      generate.view_specs false
    end

    # ...
end
```

This allow us to tailor the generators to only create the files we need.

    ~/dev/kitten_factory $ rails g controller Users
          create  app/controllers/users_controller.rb
          invoke  erb
          create    app/views/users
          invoke  assets
          invoke    scss

If you use [Suspenders](https://github.com/thoughtbot/suspenders/blob/master/lib/suspenders/app_builder.rb#L110-120), this and more will be automatically configured for you.
