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.

scaffold generator upgraded to use responder and i18n

#3888

I have changed the scaffold generator template to use the new responder syntax

I have also changed the generator templates to use i18n and created translations both for English and Spanish

Reported by javier ramirez · February 7th, 2010 @ 09:26 PM

State: wontfix
Milestone: 3.0.2
Assigned to: Mikel Lindsaar Mikel Lindsaar
Importance: Low

Activity

  1. Raul Murciano
  2. Paco Guzmán
  3. Manu Campos
  4. Mikel Lindsaar
    Mikel Lindsaar
    • Milestone cleared.
    • State changed from new to wontfix
    • Assigned user set to Mikel Lindsaar

    The reason why we have not used respond_with in the scaffolds, is that it hides too much of the implementation. The target of a scaffold is a new user, not the experienced developer who knows what is going on.

    Having this much syntax sugar going on will just overwhelm a brand new user who is trying to work out how a html page gets rendered with the scaffold.

    While the patch is good, and does what it says, I believe we will not be applying this to Rails at the moment.

    Mikel

    February 8th, 2010 @ 10:19 AM

  5. Mikel Lindsaar
  6. José Valim
    José Valim

    If you want to use respond_with on scaffold, you can get this plug and play by installing the responders gem:

    gem install responders

    Besides, if you want to customize your scaffolds, it's quite easy. Let's suppose you are using ERB and wants to customize the show.html.erb page. You just need to copy this file:

    http://github.com/rails/rails/blob/master/railties/lib/generators/e...

    To:

    RAILS_ROOT/lib/templates/erb/scaffold/show.html.erb

    And do your changes. The scaffold generator will pick this file the next time. This allows you to customize scaffold they way you want and per application, without overwhelming new users.

    February 8th, 2010 @ 10:33 AM

  7. javier ramirez
    javier ramirez

    First I want to apologize for missing ticket 3044. I searched lighthouse for "scaffold" but I somehow missed that one. Guess I was looking only for open tickets.

    My point for upgrading the generator was exactly the same as yours. Since it is going to be a tool for newbies, I wanted to make it as idiomatic as possible, using all the capabilities rails provides. If we hide the preferred/easiest method, then it's likely a new user will get used to the not-so-good way.

    I guess that's why scaffolds were changed in rails 2 to support both rest and the respond_to syntax. Should the core team have applied the same criteria back then, we would still have non-restful, non-formatted scaffolds.

    Another thing I was missing was the i18n capabilities. For a new user, it should be easier to grasp i18n if the scaffolds support it.

    Also, by having scaffolds implement the latest capabilities, I think they serve both to new and experienced users. I myself use the resource/scaffolds generators many times as a shortcut for all the boilerplate code when creating a new application. If I have i18n and responders in place, I will be saving a lot of time.

    Maybe by adding a comment at the beginning of the generated code (by the respond_to line) and then another one by the "respond_with" lines we could make it clearer for the new users, but still using an upgraded implementation.

    Thanks :)

    February 8th, 2010 @ 10:45 AM

  8. Rafa G.
  9. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    October 9th, 2010 @ 09:49 PM

  10. Jeremy Kemper
  11. bingbing