Ruby rails: scaffolds

From wikinotes
Revision as of 02:15, 10 April 2020 by Will (talk | contribs) (→‎Example)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Scaffolds allow you to very quickly create a CRUD representation of something on your website in one step.
It creates:

  • model
  • views (create, delete, update, etc.)
  • controllers

Example

rails generate scaffold Project \
  title:string \
  description:text \
  percent_complete:decimal

Afterwards you can go to any of the following:

create http://localhost:3000/projects/new
read

http://localhost:3000/projects/index
http://localhost:3000/projects/show

update http://localhost:3000/projects/edit
delete