Member-only story

Rails Generators - Configuration

Steven Klavins
3 min readMar 7, 2021

This blog is a continuation of Rails Generators - Controllers

As convenient as generators in Rails are it’s very easy to get carried away cluttering your app with unnecessary code. Thankfully Rails offers us multiple ways to avoid this issue by giving us the option to leave out unneeded files and functionality.

Configurations handled in the application.rb file.

One way of doing this is providing your generation commands with flags, for example -T is the flag for excluding test files. However, this soon gets tiresome as your app grows in size, but fear not! We can configure rails generators to conditionally exclude unneeded code. This is done from our app’s application.rb file located at config > application.rb.

By default depending on what version of rails you are using your application class will look something like this.

I have edited my application class and added the following…

class Application < Rails::Applicationconfig.generators do |g|g.orm :active_record
g.template_engine :erb
g.test_framework :test_unit, fixture: false
g.stylesheets false
g.javascripts false
end
end

So what is going on here? The config.generators do loop is fairly…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Steven Klavins
Steven Klavins

Written by Steven Klavins

Hi, I’m Steven, most call me Steve! I’m a programmer, musician, and artist. This blog contains various tutorials and posts related to software development.

No responses yet

Write a response