Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does these rails generate command differ? and what basically rails generate means?

rails generate migration
rails generate model
rails generate scaffold
rails generate controller etc.

How these differ?

like image 922
Pisto Avatar asked Nov 28 '25 09:11

Pisto


1 Answers

According to rails guides:

Using generators will save you a large amount of time by writing boilerplate code, code that is necessary for the app to work, but not necessary for you to spend time writing. That’s what we have computers for.

rails generate commands family used to provide simple and easy way for developer to create different object types.

rails generate migration - creates DB migration script in db/migrations directory so developer can setup his DB.

rails generate model - creates model class with associated migration, test and fixtures (test data).

rails generate scaffold - creates all nedded classes with basic logic and presentaion. It creates controller (with simple CRUD logic), model, fixtures, functional and unit tests.

rails generate controller - creates controller with associated functional tests, helper and basic views templates.

You can read more here: http://guides.rubyonrails.org/command_line.html#rails-generate

like image 127
Viacheslav Molokov Avatar answered Nov 29 '25 21:11

Viacheslav Molokov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!