Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm learning Ruby on Rails for a new project of mine. I am referring the book 'Agile Web Development with Rails' which shows how to build a shopping cart and they use scaffolding.

I'm pretty familiar with MVC architecture and have used several frameworks in PHP to build applications. I've never used scaffolding and I'm not sure if that's the best way to start building an application.

Experienced users, please suggest if I should be using scaffolding or should I code manually.

share|improve this question

closed as primarily opinion-based by MichaelT, durron597, GlenH7, Snowman, Kilian Foth Jul 30 '15 at 9:55

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 5 down vote accepted

Go ahead and use scaffolding. Scaffolding is just a way to get some working code quickly. It's not a commitment. Often the hardest part with a new technology is getting the first thing working. RoR scaffolding gets you over that hurdle, and then you can replace or extend the scaffold code bit by bit.

share|improve this answer
True that. I'll go ahead and use scaffolding for learning the language and framework quickly. Thanks :) – Deepak Mittal Jun 24 '11 at 10:36

As you are a beginner you should use it. Because you may not all the syntax in that case scaffolding can help you out. I generally use it. Because it saves lot of time as it generate good amount of code and in most case error free. So I will suggest you to use scaffolding in RoR. And the generated is easy to understand so can update it as your need.

Why to do it manually when it can be done automatically which saves time?

share|improve this answer
I feared if the code generated would be difficult to modify. I've had bad experiences with modifying other's code. Thanks, I'll use scaffolding. – Deepak Mittal Jun 24 '11 at 7:58
@dpacmittal: Don't worry. The generated code is very simple and you will easily understand it and can easily modify it. And if you still get problem in it then feel free to discuss about problem. – Harry Joy Jun 24 '11 at 8:07

One of the key reasons is that it will create the database stuff (CRUD) for you. You won't have to write the same boring code every time you want to generate a new model.

Also, if you're using Rails 3 or later, the scaffold produces less redundant code (when it comes to view forms) than 2.x.x, if I'm not mistaken.

The other generators are also useful, I would recommend using them as much as possible.

share|improve this answer

Use it while learning, but understand what it does so you don't rely on it. In many cases using the scaffold will help you get the app up and running quickly (and you can always modify it later and take out the parts you don't need), but make sure that you know how to do it by hand if you need to fix things with the scaffold or if you need to later do something that doesn't require the scaffold.

In short: Scaffolding is a tool, not a crutch, and should be treated like a tool in your arsenal.

share|improve this answer

There's good and bad ways to do scaffolding. I strongly discourage anyone using the default rails scaffolds—the HTML it produces isn't particularly good, and its static.

What I do recommend is the use of something like formtastic to do your scaffolds. You can start with something as simple as

<%= semantic_form_for @model do |form| %>
  <%= form.inputs %>
  <%= form.buttons %>
<% end %>

and get something that's at least as functional as the default scaffolds, and a heck of a lot smarter. you can easily grow into an actual application with it just by replacing the form.inputs with a more defined set of fields you want to appear.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.