Search code examples
ruby-on-railsscaffolding

What is Rails’ scaffold functionality


I recently starting trying out ruby on rails and I am not sure what scaffolds are for in rails.

Say I run this command: rails generate scaffold idea name:string description:text picture:string

What exactly is it doing apart from creating new files in your project directory? Is it creating a table for the database?

Thank you very much.


Solution

  • Take a look at the Rails guide on scaffolding.

    When you use the generate scaffold command, you're creating a migration (which will create a table when you run rake db:migrate), views, css, script files, initial tests, etc. Think of the literal meaning of the term "scaffold" as "a structure around which something is constructed" and scaffolding starts to make a lot of sense.