# Understanding the Power of rails g scaffold

DevFeed: [Understanding the Power of rails g scaffold](<https://devfeed.tech/articles/understanding-the-power-of-rails-g-scaffold-28254.md>)

Original publisher: [Read original article](<http://fuzzyblog.io/blog/rails/2020/01/22/understanding-the-power-of-rails-g-scaffold.html>)

Author: Fuzzygroup

Published: 2020-01-22T00:00:00Z

Content type: tutorial

Language: en

Sources: [Scott Johnson](<https://devfeed.tech/sources/scott-johnson.md>)

Topics: [Rails](<https://devfeed.tech/topics/rails.md>), [generators](<https://devfeed.tech/topics/generators.md>), [Testing](<https://devfeed.tech/topics/testing.md>), [coding](<https://devfeed.tech/topics/coding.md>)

Tags: [authorization](<https://devfeed.tech/tags/authorization.md>), [controllers](<https://devfeed.tech/tags/controllers.md>), [generators](<https://devfeed.tech/tags/generators.md>), [models](<https://devfeed.tech/tags/models.md>), [rails](<https://devfeed.tech/tags/rails.md>), [route](<https://devfeed.tech/tags/route.md>), [security](<https://devfeed.tech/tags/security.md>), [testing](<https://devfeed.tech/tags/testing.md>), [tests](<https://devfeed.tech/tags/tests.md>)

## AI overview

This Rails tutorial explains how the `rails g scaffold` command generates a model, migration, controller, routes, views, helpers, stylesheets, and tests. It also discusses its benefits for rapid prototyping and quality, along with limitations such as no built-in factories or authorization.

## Source excerpt

Wow. I am a damn idiot who has literally made his life harder than it ever needed to be -- for years. Sigh. I am referring to the Rails generator and the scaffold command. When you have complex software tools, sometimes you don't discover features - great damn features - for a long time. In this case I'm referring to: rails g scaffold pluralized_object_name In my case, I'm building a project where the ultimate goal is to create a label on something. Never mind what a label is or what the something is. A friend I've been helping with Rails recently asked me what rails g scaffold does and I muttered something about "makes the model and controller in one go" but I never thought to try it myself until just now. HOLY CRAP! Wow. rails g scaffold labels And here's what this generated for me: rails g scaffold Labels Running via Spring preloader in process 78104 [WARNING] The model name 'Labels' was recognized as a plural, using the singular 'Label' instead. Override with --force-plural or setup custom inflection rules for this noun before running the generator. invoke active_record create db/migrate/20200122100533_create_labels.rb create app/models/label.rb invoke test_unit create test/models/label_test.rb create test/fixtures/labels.yml invoke resource_route route resources :labels invoke scaffold_controller create app/controllers/labels_controller.rb invoke erb create app/views/labels create app/views/labels/index.html.erb create app/views/labels/edit.html.erb create app/views/labels/show.html.erb create app/views/labels/new.html.erb create app/views/labels/_form.html.erb append app/views/shared/_left_nav.html.erb invoke test_unit create test/controllers/labels_controller_test.rb create test/system/labels_test.rb invoke helper create app/helpers/labels_helper.rb invoke test_unit invoke assets invoke scss create app/assets/stylesheets/labels.scss And this isn't just creating a raw file structure, the core controller itself and the tests are actually built for you. Here's th