Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do Ruby on Rails professionals NOT use Scaffolding?

I read sometimes from people that seem to be working with rails since longer, that one important lesson they learnt would be "Don't use scaffolding". Also on irc I read commonly hints from this direction. My question is why, what is the bad thing about it? And is nifty_scaffolding bad as well?

My guess would be it is bad because it generates by default an xml version of your controller action, which would expose the field names of our application to anybody and make it more vulnerable for attacks, so maybe it's this?

What are your reasons to not do scaffolding?

like image 799
tmaximini Avatar asked Jul 18 '11 15:07

tmaximini


2 Answers

I'm experienced with rails and I rarely use scaffolding simply because my end goal is far from simple CRUD actions. However, there's no strict rule to not use scaffolding. Some coders frown on it because it is actually scaffolding, literally. It's not a finished product. Scaffolding supports you as you build the actual product. Search google images for "scaffolding" and you should get the idea.

Keep in mind scaffold is just one of many built-in generators in Rails. A Rails generator is simply a script that outputs some generic code. Generators are very useful time-savers, and you'll quickly find yourself writing generators for your own custom needs.

like image 58
tybro0103 Avatar answered Sep 23 '22 22:09

tybro0103


I believe most professionals avoid scaffolding because they prefer a test driven development approach to writing production code. This means they want to write a failing test first and then write the code that makes the test pass. This is a great way of producing strong code, but it works best at a very granular level. Scaffolding seems to do too much at one time and so it disrupts a tight loop of writing a failing test for a specific features then writing the code that makes that particular feature pass. It may be more important to get into that habit above and beyond the ease of use of scaffolding.

That said scaffolding can be pretty powerful in its own right.

like image 41
Michael K Madison Avatar answered Sep 21 '22 22:09

Michael K Madison