5 min

031 RC Generators Rails Coach

    • Tecnología

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 en Tecnología

Acquired
Ben Gilbert and David Rosenthal
Top Noticias Tech
Tech Santos
Search Engine
PJ Vogt, Audacy, Jigsaw
All-In with Chamath, Jason, Sacks & Friedberg
All-In Podcast, LLC
Nosotros Los Clones
NOSOTROS LOS CLONES
Lex Fridman Podcast
Lex Fridman

Más de DevChat.tv

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