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.

Array-like browsing for models

#557

I came up with an idea (patch added), to allow array-like browsing of models.

Example: instead of using Model.find(params[:id]), you can use Model[params[:id]]

Reported by Bryce · July 7th, 2008 @ 06:51 AM

State: wontfix
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Clemens Kofler
    Clemens Kofler

    I think I've once seen this in a plugin and I didn't like it. Model.find makes it really clear what's going on (i.e. finding an object) where Model[] (IMO) doesn't. It's a mere shortcut where you give up clarity for brevity and I don't like it, sorry.

    July 7th, 2008 @ 03:21 PM

  2. José Valim
    José Valim

    I agree with Clemens!

    July 7th, 2008 @ 03:29 PM

  3. Josh Susser
    Josh Susser

    Another -1 here. I've taken to using the [] for working with models in a certain way. Like the Setting class can interact with its settings using Setting[:foo] and Setting[:foo] = 17. I'd rather retain that flexibility than save a few characters and give up clarity.

    July 7th, 2008 @ 03:44 PM

  4. Alex MacCaw
    Alex MacCaw

    -1 It wouldn't work with associations either

    July 7th, 2008 @ 04:00 PM

  5. Pratik
    Pratik
    • State changed from new to wontfix

    July 7th, 2008 @ 04:54 PM