This project is archived and is in readonly mode.

#3867 ✓wontfix
Steve Erickson

add modify in place setters for relations

Reported by Steve Erickson | February 5th, 2010 @ 09:10 PM

While playing around with Arel I was surprised to find that there were no setters to modify a relation. In other words, "bang" methods (!) to update a relation using multiple calls. I think it would be nice if the following were possible:

users = Table[:users]

users.where!(users[:id].eq(1))

This would make it possible to use conditionals when generating a query.

I realize I can achieve a similar effect today just by storing the results of a where call into a new variable, but I think the bang methods are more elegant.

Thanks for your consideration.

Comments and changes to this ticket

  • Pratik

    Pratik February 6th, 2010 @ 12:07 PM

    • State changed from “new” to “wontfix”

    Most of the core team believes that it's great to have immutability and is the recommended way. So I don't see ! methods making it to the core. However, it should be simple to write a plugin for it.

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>

People watching this ticket

Pages