[Rails] delete_if doesn't work for has_and_belongs_to_many

dblack at wobblini.net dblack at wobblini.net
Wed Aug 9 02:37:28 GMT 2006


Hi --

On Tue, 8 Aug 2006, John Anderson wrote:

>> From my point of view, another way of seeing it is this: why is there a
> method that does something very unexpected (ie not manipulate records in
> the db when that's the express purpose of the collection in question),
> when it doesn't even need to exist since there are other ways to achieve
> the same functionality?

It's interesting that push is magic, but pop isn't :-)  And same with
delete and delete_if.  Also, while you can't do:

   ar_collection << 100

you *can* do:

   ar_collection[1] = 100

I guess it's a tradeoff between the vanilla array behavior and the
special AR behavior -- though in some of these cases a case could
certainly be made for some kind of unification.


David

-- 
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
   ----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <-----
http://dablog.rubypal.com        => D[avid ]A[. ]B[lack's][ Web]log
http://www.manning.com/black     => book, Ruby for Rails
http://www.rubycentral.org       => Ruby Central, Inc.


More information about the Rails mailing list