Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Remove railties/.../scaffold_generator.rb: template "layout.html.erb"

#3555

Rails has the ability to share layouts between controllers, primarily by repeating "layout 'application'" in each controller. This isn't very DRY.

Common techniques to refactor this out (such as inheritance) are thwarted by the fact that scaffold generator produces a new layout for each controller, and such (often unwanted) templates will be chosen first, over the expressed wishes of the superclass. This behavior is surprising and complicates teaching. Agile Web Development with Rails, Edition 3, for example, has taken the approach of establishing a common layout for the Depot application and then instructing the reader to delete the generated layout after each and every call to the scaffold generator.

My suggestion is that Rails::Generators::AppGenerator produce a single layout based on the application name and reference it in application_controller. This may create migration concerns, so perhaps scaffold_generator should continue to produce controller-specific layouts, but only if ApplicationController.instance_eval('@_layout') is nil.

I'm willing to write patches, test the code, whatever; but first I'm seeking agreement on what the desired behavior should be.

Reported by Sam Ruby · December 9th, 2009 @ 12:54 PM

State: invalid
Milestone: 3.0.2
Assigned to: nobody
Importance: none

Activity

  1. Sam Ruby
    Sam Ruby
    • State changed from new to invalid
    • Assigned user cleared.

    Already is an option:

    config.generators.layout false
    script/generate scaffold posts --layout=false
    script/generate scaffold posts --no-layout

    January 3rd, 2010 @ 12:35 AM

  2. Jeremy Kemper