# 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: article

Language: en

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

Topics: [Ruby on Rails](<https://devfeed.tech/topics/ruby-on-rails.md>), [mvc](<https://devfeed.tech/topics/mvc.md>), [Software Testing](<https://devfeed.tech/topics/software-testing.md>), [Test automation](<https://devfeed.tech/topics/test-automation.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [access-control](<https://devfeed.tech/tags/access-control.md>), [active-record](<https://devfeed.tech/tags/active-record.md>), [assets](<https://devfeed.tech/tags/assets.md>), [authorization](<https://devfeed.tech/tags/authorization.md>), [code](<https://devfeed.tech/tags/code.md>), [command](<https://devfeed.tech/tags/command.md>), [controller](<https://devfeed.tech/tags/controller.md>), [controllers](<https://devfeed.tech/tags/controllers.md>), [generator](<https://devfeed.tech/tags/generator.md>), [html](<https://devfeed.tech/tags/html.md>), [model](<https://devfeed.tech/tags/model.md>), [models](<https://devfeed.tech/tags/models.md>), [rails](<https://devfeed.tech/tags/rails.md>), [resources](<https://devfeed.tech/tags/resources.md>), [route](<https://devfeed.tech/tags/route.md>), [scss](<https://devfeed.tech/tags/scss.md>), [spring](<https://devfeed.tech/tags/spring.md>), [test](<https://devfeed.tech/tags/test.md>), [tests](<https://devfeed.tech/tags/tests.md>)

## AI overview

Running `rails g scaffold labels` generated a migration, singular `Label` model, resource route, CRUD controller, views, fixtures, controller and system tests, helper, and stylesheet. The output warned that `Labels` was plural and normalized the model name to `Label`, with `--force-plural` or custom inflection rules offered as alternatives. The author says scaffolding speeds prototyping and supplies a testable controller, while noting that factories and authorization are not generated by default. They describe generators as customizable, with possible additions such as factory files, access control, policies, and logged-in/logged-out controller tests. The excerpt does not show the full article.

## 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