5 min

031 RC Generators Rails Coach

    • Technology

A generator is a way of creating code from the command line. Rails has several of these built in, including generators for models, controllers, tests, helpers, scaffold (models, views, and controllers that support Rails' RESTful routing), and much more.

Generators are actually relatively simple. They are made up of two parts. The generator itself, and the generator's templates. In the Ruby on Rails source code there's an assets generator and the javascript template and stylesheet templates it uses.

I've also created a model generator for my Sandra ORM. You can find it here.

Understanding how models work, you can see how simple it is for the Rails Core Team to build in generators for other things like models, controllers, helpers, tests, assets, mailers, etc.

To see the full list of generators available in a Rails application run `rails generate` or `rails g`.

To create your own generators in your project, put them under /lib/generators or better yet, use the generator for generators like this: `rails generate generator widget` and you'll get a widget generator all set up for you in the /lib/generators folder that's ready for you to customize.

A generator is a way of creating code from the command line. Rails has several of these built in, including generators for models, controllers, tests, helpers, scaffold (models, views, and controllers that support Rails' RESTful routing), and much more.

Generators are actually relatively simple. They are made up of two parts. The generator itself, and the generator's templates. In the Ruby on Rails source code there's an assets generator and the javascript template and stylesheet templates it uses.

I've also created a model generator for my Sandra ORM. You can find it here.

Understanding how models work, you can see how simple it is for the Rails Core Team to build in generators for other things like models, controllers, helpers, tests, assets, mailers, etc.

To see the full list of generators available in a Rails application run `rails generate` or `rails g`.

To create your own generators in your project, put them under /lib/generators or better yet, use the generator for generators like this: `rails generate generator widget` and you'll get a widget generator all set up for you in the /lib/generators folder that's ready for you to customize.

5 min

Top Podcasts In Technology

DOU Podcast
DOU
Радио-Т
Umputun, Bobuk, Gray, Ksenks, Alek.sys
Інтерфейсний
Yan Hladchenko
Подкаст ЖеПеТе
Влад Кампов, Влад Сидоренко
Nextech
Влад Ноздрачов
Lex Fridman Podcast
Lex Fridman

More by DevChat.tv

React Native Radio
Jamon Holmgren, Robin Heinze, Mazen Chami
JavaScript Jabber
Charles M Wood
Adventures in Angular
Charles M Wood
Rails Coach
Charles Max Wood
JavaScript Jabber
Charles M Wood
Ruby Rogues
Charles M Wood