views:

9900

answers:

4

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?

THANKS!

P.S. The answers to my two questions would help for now, too :)

+5  A: 

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.

Ronnie Liew
Awesome. Just in the nick of time, too...
Yar
+2  A: 

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

Eric Davis
Thanks Eric, that is also good information...
Yar
+11  A: 

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.

Andrew Vit
Cool, thank you avit.
Yar
+2  A: 

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

DrwMak
Nice, thanks for that. +1
Yar