Re: [Rails-core] ActiveRecord Query `[]` Function

2013-07-19 Thread James Coleman
The whole point of the `all` method is that it actually fires the query on the current relation. So 1.) a change like this could potentially break a lot of existing code and 2.) it would defeat the point of the method. So I strongly believe that it shouldn't change. If you want the limit/offset que

Re: [Rails-core] ActiveRecord Query `[]` Function

2013-07-19 Thread Matt Daubert
I agree very much with James and would add that if iteration was done in this manner it would not improve performance since the additional queries add round-trip time (latency, db query setup, etc) which typically exceeds time spent returning results, especially in multi-tier environments. In my

Re: [Rails-core] ActiveRecord Query `[]` Function

2013-07-19 Thread James Coleman
>> "As far as idiomatics are concerned, `all` returning an eagerly-loaded array is more idiomatic to me than `all` returning a proxy that quacks like an array but lazily-loads items." Particularly given that relations are already themselves proxies that generally quack like arrays but lazily-load

Re: [Rails-core] Pull requests on Github

2013-07-19 Thread Yves Senn
I can only agree with my previous speakers. While there are a lot of issues, the team is very active. The easy issues are mostly resolved within days and the harder ones of course stay longer. Important issues are usually identified and dealt with priority. I think everyone who wants to help th

Re: [Rails-core] ActiveRecord Query `[]` Function

2013-07-19 Thread Simon Courtois
I disagree with the addition of `all[X]` but isn't `all` supposed to not fire the the query and return some kind of ActiveRecord::Relation now ? If so, the `[]` addition would be made on it and I don't think it would be a good thing :/ Simon Courtois On Friday 19 July 2013 at 13:40, James Col

Re: [Rails-core] ActiveRecord Query `[]` Function

2013-07-19 Thread Matthew MacLeod
On Friday, July 19, 2013 1:47:37 PM UTC+1, James Coleman wrote: Particularly given that relations are already themselves proxies that > generally quack like arrays but lazily-load items. The `all` method is > specifically there so that you can *break out* *of that proxy*. > As of Rails 4, Model

[Rails-core] Pull request #11486 -- implement respond_to_missing for TaggedLogging in Rails 3.2

2013-07-19 Thread Wolfram Arnold, RubyFocus
Folks, I've sent a pull request https://github.com/rails/rails/pull/11486 which fixes an issue with TaggedLogging for Rails 3.2. From what I can tell that's the only release that affected. The issue was that method_missing was overridden correctly in TaggedLogging, but respond_to_missing? was

[Rails-core] Why last doesn't return an ActiveRecord::Relation

2013-07-19 Thread Robin Dupret
Hello, Sorry if this has been still answered, I haven't found nothing on it. I would love to know why ActiveRecord::Base#last doesn't return an ActiveRecord::Relation just like all or where since an ActiveRecord::Relation can act more or less like an array (as specified here

Re: [Rails-core] Pull requests on Github

2013-07-19 Thread Steve Klabnik
One last point I'd like to make is that 'just giving more people commit' isn't going to work out. Merging bad pull requests just to get the numbers down isn't going to help. It would just add more work to clean up any messes. The only way to get more committers is for more people to do more work,

Re: [Rails-core] Why last doesn't return an ActiveRecord::Relation

2013-07-19 Thread Mohamed Wael Khobalatte
Because you won't need to run a query on one element? On Wed, Jul 17, 2013 at 11:33 AM, Robin Dupret wrote: > Hello, > > Sorry if this has been still answered, I haven't found nothing on it. I > would love to know why ActiveRecord::Base#last doesn't return an > ActiveRecord::Relation just like a

Re: [Rails-core] ActiveRecord Query `[]` Function

2013-07-19 Thread James Coleman
Regardless of whether or not it might be a nice idiomatic style to be able to have, I think this discussion comes back around to what a lot of others ones on this list do as well: the change would be a pretty big potentially breaking change to existing code. So there's no real good reason to make t

Re: [Rails-core] Why last doesn't return an ActiveRecord::Relation

2013-07-19 Thread Tejas Dinkar
On Jul-19-2013, at 8:08 PM, Mohamed Wael Khobalatte wrote: > Because you won't need to run a query on one element? I think the question is more about Model.last(5) or Model.first(5) These return arrays when they could return a relation. -- Tejas Dinkar http://www.nilenso.com Nilenso Software

[Rails-core] Re: Why last doesn't return an ActiveRecord::Relation

2013-07-19 Thread Andrew Vit
"first" and "last" have always returned an instance of the model. These are meant to be the final method that you call on a relation, to get the result. If you call "last(5)" it will return an array, and that's the correct behaviour since that's the result of the query. If you need the relation

Re: [Rails-core] Why last doesn't return an ActiveRecord::Relation

2013-07-19 Thread Mohamed Wael Khobalatte
Gotcha. In this case, since calls to Model.last(n) is inherently inefficient (loading everything and placing a limit), it's good to keep it till the end of the chain. On Fri, Jul 19, 2013 at 11:55 AM, Tejas Dinkar wrote: > On Jul-19-2013, at 8:08 PM, Mohamed Wael Khobalatte < > wael.khobala...@g

Re: [Rails-core] Re: Why last doesn't return an ActiveRecord::Relation

2013-07-19 Thread Daniel Evans
"last(5)" is, with regard to efficiency, equivalent to "limit(5).to_a". On Fri, Jul 19, 2013 at 2:28 PM, Andrew Vit wrote: > "first" and "last" have always returned an instance of the model. These > are meant to be the final method that you call on a relation, to get the > result. If you call "