Where are the docs for Rails "script/generate model"?

23k views Asked by At

I am running

ruby script/generate scaffold

or

ruby script/generate model

and I know the basic syntax, like

ruby script/generate scaffold Dude name:string face:boolean

but I do not know things like:

  • should names of variables have underscores or be camelCased?
  • what kind of variable types are acceptable?

Where can I find such information?

5

There are 5 answers

0
Andrew Vit On BEST ANSWER

Type the command without arguments and the documentation is revealed:

$ script/generate model

You can use either camelcase or underscores for the model name.

  • Model names are singular; controller names are plural.
  • Field names use underscores.

I can't remember all the possible field types, I just look them up from the Migration docs, as linked above.

0
igor On

there is a new syntaxis for Rails is rails generate

0
drew.macleod On

There is a resource on the rails wiki as a List of Available Generators.

0
Ronnie Liew On

This document on Rails Migration would help.

With respect to the naming convention, I think the general adopted convention for Ruby on Rails is to have underscores.

To know which variable types are acceptable, refer to the section on Database Mapping.

0
Eric Davis On

To check Rails naming conventions, topfunky's Pluralizer was useful.