Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate 2 models by using rails generate command?

I am wondering how to use generate command to do something like this:

rails g model order customer

but it doesn't work.

Please show me how to do this, and how to check all the usage of this command?

like image 555
mko Avatar asked Dec 10 '10 03:12

mko


People also ask

What is the Rails command to create model?

A Rails Model is a Ruby class that can add database records (think of whole rows in an Excel table), find particular data you're looking for, update that data, or remove data. These common operations are referred to by the acronym CRUD--Create, Remove, Update, Destroy.

What does Rails generate do?

The generate command in Rails is a powerful tool that you can use to streamline workflow. You can use the generate command in the command line to quickly create boilerplate folders and files for a project.


2 Answers

You will need to execute one command per model:

rails g model Order
rails g model Customer

The model generator is defined like this:

alt text

like image 199
Jacob Relkin Avatar answered Nov 15 '22 04:11

Jacob Relkin


Unfortunately, you will have to settle for:

rails g model Order
rails g model Customer
like image 20
Swanand Avatar answered Nov 15 '22 03:11

Swanand