This project is archived and is in readonly mode.

#557 ✓wontfix
Bryce

Array-like browsing for models

Reported by Bryce | July 7th, 2008 @ 06:51 AM | in 2.x

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]]

Comments and changes to this ticket

  • Clemens Kofler

    Clemens Kofler July 7th, 2008 @ 03:21 PM

    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.

  • José Valim

    José Valim July 7th, 2008 @ 03:29 PM

    I agree with Clemens!

  • Josh Susser

    Josh Susser July 7th, 2008 @ 03:44 PM

    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.

  • Alex MacCaw

    Alex MacCaw July 7th, 2008 @ 04:00 PM

    -1 It wouldn't work with associations either

  • Pratik

    Pratik July 7th, 2008 @ 04:54 PM

    • State changed from “new” to “wontfix”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Pages