On Fri, Mar 9, 2012 at 7:06 PM, Steve Klabnik <[email protected]> wrote: >> Scaffolds are a boon to someone trying to work it out for themselves >> and they provide the instant gratification Wow factor that lets them >> get something up and running like magic. They did exactly that for >> me. > > This doesn't address the fact that scaffolds teach the learner > incorrect things.
Could we get technically specific on which "incorrect" things the scaffold brings? Maybe we could try to fix those specific issues (on a technical and documentation level). On a technical level, I see 3 specific (but fixable) problems: * the issue with attr_accessible is not explained (so the application is vulnerable to owner_of_record_id being set to another owner as in the recently publicized case). I see solutions for that (changing the code, in the direction suggested recently by @dhh (that is not attr_accessible, but a local function in the controller that slices the params in the controller context) and adding explanation about it). * the default auto-generated controller rspec tests have a few minor issues that make those tests brittle (comes down to slightly improving that format) * the views have a horrible amount of repetition. We should have a simple loop there doing each over an array of [:field_name, :type] entries (that structure is available anyway to produce the migration). That approach would also make it trivial to manually add and remove a few fields later on. Optimally that list of "active fields" in the new and edit views should be the slice list for filtering the incoming params in create and update actions (IMO that is the proper solution for the attr_accesible issue and it would be not too difficult to bake that right into the scaffold code). Besides these 3 issues, rails g scaffold continues to be valuable to me. E.g. I have actively used it this week to bootstrap a new project. The valuable points for me where: * migrations are made automatically * I get a an initial framework of rspec tests (model controller, views) that give a basic test scaffold as I start adapting the application to the real use case. * I had an immediate view on the actual data in existing production db. On a more general note, I would certainly want to continue to use scaffolds, in one form or another. HTH, Peter -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
