Technology Insights

Rails resource vs Rails scaffold

What’s the difference between a scaffold and resource in Ruby on Rails? Essentially, the only difference is that the views (and associated layout and css file) for index, show, new and edit are created. The output when generating both the scaffold and the resource (with the command line generator) are shown below.

Technology Insights

What Exactly Does the Scaffold_Resource Generator give you?

The regular scaffold generator (e.g. ruby script/generate scaffold model controller) requires you to create your model and controller first. The scaffold_resource generator, on the other hand, generates the (RESTful) model and controller for you. For example: ruby script/generate scaffold_resource Caregiver first_name:string last_name:string In Rails 2.0, use resource instead: ruby script/generate resource Caregiver first_name:string last_name:string Here’s…