18

In the Ruby on Rails tutorial, I read something that suggested that experienced developers do not use scaffolding since they tend to like to just write the code to connect the MVC on their own.

In a different place I read that it is a good idea to use scaffolding because it helps you stick to convention so others who look at and interact with your code will understand what you are doing.

I am pretty new to Ruby on Rails but not MVC or web application - should I generally try hard to stick to scaffolding conventions and let it guide me?

alternative
  • 1,542
  • 13
  • 14
Genadinik
  • 509
  • 1
  • 3
  • 11
  • 2
    I put in an edit submission to change Ruby in the title to Ruby on Rails, if thats okay. – alternative May 09 '11 at 21:34
  • @mathepic Yup, makes more sense now - thanks for doing that. – Genadinik May 09 '11 at 21:59
  • Disagree a bit if you do know programming but never used rails absolutely first create product scaffold and see what it created compared to emply app. This is absolutely fastest way to figure how everything links together and what the naming conventions (really important in rails) are. After that destroy the scaffold and build by hand. – Kimmo Hintikka Mar 09 '16 at 20:27

7 Answers7

19

Scaffolding serves a purpose - it's a rapid prototyping tool. Use it if that is what you are doing. Once you have your prototype, you can intelligently make the decision to modify what the scaffolding produced for you, or delete the scaffolding and build up the app exactly as you want it.

If this is your first rails application, I strongly recommend however that you don't use scaffolding. As a learning exercise, nothing teaches better than getting down to the metal and seeing exactly what you need to get an app up and running.

Hope this helps!

idbentley
  • 306
  • 1
  • 4
  • It helps and I see your point. The application IS meant for others to use though, so I am just trying to get enough background so I can get most things architected right on my own. – Genadinik May 09 '11 at 23:12
4

I use it, for the simple reason that it's quicker to delete unneeded code from what the scaffold generates than to create all the files and code manually.

If I were you I would at least try it for yourself and see if what it puts out is mostly useful or not.

pthesis
  • 776
  • 6
  • 13
3

I've never used it in 4 years of building Rails apps. It can be useful in some situations I suppose. The nice thing about it is that it's an obvious temporary UI, so no one will try to go live with it.

The same cannot be said about ActiveScaffold (in case you come across it). It looks like a shippable UI, and management might be fooled into thinking that the UI is good to go and ask you to ship. Don't! In fact, I'm already regretting I mentioned AS.

Julio
  • 1,854
  • 13
  • 10
2

I developed many websites with RoR and in the company I worked we never used it. I think that is true for most RoR developers. Though I remember a few discussions about this and some professional developers where using it in some circumstances.

But I think they didn't use the default version of Rails scaffolding, implementing their own variation instead. This may work especially well if you do in house work for large companies, where the design doesn't change a lot (or doesn't matter) and you need a lot of views on the same kind of data for statistics or similar repetitive tasks.

thorsten müller
  • 12,058
  • 4
  • 49
  • 54
2

To echo what others have said, when I use Rails I use scaffolding but I don't rely on scaffolding, if that makes sense. Often I need 90% of what the scaffold generates, so it's easier to run the generator and then remove what I don't need (e.g. the "HTML or XML" stuff if I don't need XML) than to write all of the same code by hand. You don't do anything but waste keystrokes.

If you're learning, then you should write it by hand so you know what it does and why it does it, and then later on start using the scaffolding to quickly generate that code. IMO a professional Rails developer knows when to use scaffolding, and when to use it to generate some basic code and then modify it as needed for the app at hand.

Wayne Molina
  • 15,644
  • 10
  • 56
  • 87
1

In short: no.

I'll use generators but I almost never use scaffolds anymore. You tend to spend a fair bit of time editing the scaffolds and it gets a bit unweilding.

I find a good compromise to use the controller generators can get you up and running pretty quick if you are doing top-down development.

scottschulthess
  • 137
  • 1
  • 5
1

I started my app with scaffolding, but by the third entity when I started to deviate from the "RoR way", I found it useless.

Soronthar
  • 279
  • 1
  • 4