Dan Rosenstark
Dan Rosenstark

Reputation: 69767

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

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:

Where can I find such information?

Upvotes: 21

Views: 23038

Answers (5)

Ronnie Liew
Ronnie Liew

Reputation: 18270

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.

Upvotes: 10

igor
igor

Reputation: 21

there is a new syntaxis for Rails is rails generate

Upvotes: 2

drew.macleod
drew.macleod

Reputation: 143

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

Upvotes: 6

Andrew Vit
Andrew Vit

Reputation: 19249

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.

Upvotes: 27

Eric Davis
Eric Davis

Reputation: 1837

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

Upvotes: 3

Related Questions