Commit http://github.com/rails/rails/commit/517bc500ed95a84fd2aadff34fdc14cb7965bc6bintroduced the new method proxy_respond_to?, but it has a bug. Suppose the following case (it''s using will_paginate plugin) class User < ActiveRecord::Base has_many :articles end Then you call: u = User.first u.articles # => [some articles...] u.articles # => ArgumentError: wrong number of arguments (2 for 1) from .../activerecord/lib/active_record/associations/association_proxy.rb:78:in `proxy_respond_to?'' from .../activerecord/lib/active_record/associations/association_proxy.rb:78:in `respond_to?'' from .../vendor/plugins/will_paginate/lib/will_paginate/finder.rb:155:in `respond_to?'' from .../activerecord/lib/active_record/associations.rb:1287:in `articles'' from (irb):3 As you can see, the bug is caused in the will_paginate plugin because it pass two params to the super respond_to? def respond_to?(method, include_priv = false) #:nodoc: case method.to_sym when :paginate, :paginate_by_sql true else super(method.to_s.sub(/^paginate/, ''find''), include_priv) end end So the fix should be adding an extra param to proxy_respond_to? def proxy_respond_to?(method, include_priv = false) super || @reflection.klass.respond_to?(method, include_priv) end How could I test this to submit a patch? PS: Even this is kinda curious because it throws the Exception after the second time it''s called, not the first one. Haven''t gone that deep yet. Regards. Edgar J. Suarez --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Sorry for the commit link, it is: http://github.com/rails/rails/commit/517bc500ed95a84fd2aadff34fdc14cb7965bc6b / introduced the new method proxy_respond_to?... Edgar J. Suarez On Oct 16, 3:57 pm, "Edgar J. Suárez" <edgar...@gmail.com> wrote:> Commithttp://github.com/rails/rails/commit/517bc500ed95a84fd2aadff34fdc14cb...> the new method proxy_respond_to?, but it has a bug. > > Suppose the following case (it''s using will_paginate plugin) > > class User < ActiveRecord::Base > has_many :articles > end > > Then you call: > > u = User.first > u.articles # => [some articles...] > u.articles # => > ArgumentError: wrong number of arguments (2 for 1) > from > .../activerecord/lib/active_record/associations/association_proxy.rb:78:in > `proxy_respond_to?'' > from > .../activerecord/lib/active_record/associations/association_proxy.rb:78:in > `respond_to?'' > from > .../vendor/plugins/will_paginate/lib/will_paginate/finder.rb:155:in > `respond_to?'' > from .../activerecord/lib/active_record/associations.rb:1287:in > `articles'' > from (irb):3 > > As you can see, the bug is caused in the will_paginate plugin because it > pass two params to the super respond_to? > > def respond_to?(method, include_priv = false) #:nodoc: > case method.to_sym > when :paginate, :paginate_by_sql > true > else > super(method.to_s.sub(/^paginate/, ''find''), include_priv) > end > end > > So the fix should be adding an extra param to proxy_respond_to? > > def proxy_respond_to?(method, include_priv = false) > super || @reflection.klass.respond_to?(method, include_priv) > end > > How could I test this to submit a patch? > > PS: Even this is kinda curious because it throws the Exception after the > second time it''s called, not the first one. Haven''t gone that deep yet. > > Regards. > > Edgar J. Suarez--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Hey Edgar, Does http://github.com/rails/rails/commit/95c609357e78106e9673931d3f60d8ff3cc0a0cd fix it for you ? Thanks. On Thu, Oct 16, 2008 at 11:03 PM, Edgar J. Suárez <edgar.js@gmail.com> wrote:> Sorry for the commit link, it is: > > http://github.com/rails/rails/commit/517bc500ed95a84fd2aadff34fdc14cb7965bc6b > > / introduced the new method proxy_respond_to?... > > Edgar J. Suarez > > On Oct 16, 3:57 pm, "Edgar J. Suárez" <edgar...@gmail.com> wrote: >> >> Commithttp://github.com/rails/rails/commit/517bc500ed95a84fd2aadff34fdc14cb... >> the new method proxy_respond_to?, but it has a bug. >> >> Suppose the following case (it''s using will_paginate plugin) >> >> class User < ActiveRecord::Base >> has_many :articles >> end >> >> Then you call: >> >> u = User.first >> u.articles # => [some articles...] >> u.articles # => >> ArgumentError: wrong number of arguments (2 for 1) >> from >> .../activerecord/lib/active_record/associations/association_proxy.rb:78:in >> `proxy_respond_to?'' >> from >> .../activerecord/lib/active_record/associations/association_proxy.rb:78:in >> `respond_to?'' >> from >> .../vendor/plugins/will_paginate/lib/will_paginate/finder.rb:155:in >> `respond_to?'' >> from .../activerecord/lib/active_record/associations.rb:1287:in >> `articles'' >> from (irb):3 >> >> As you can see, the bug is caused in the will_paginate plugin because it >> pass two params to the super respond_to? >> >> def respond_to?(method, include_priv = false) #:nodoc: >> case method.to_sym >> when :paginate, :paginate_by_sql >> true >> else >> super(method.to_s.sub(/^paginate/, ''find''), include_priv) >> end >> end >> >> So the fix should be adding an extra param to proxy_respond_to? >> >> def proxy_respond_to?(method, include_priv = false) >> super || @reflection.klass.respond_to?(method, include_priv) >> end >> >> How could I test this to submit a patch? >> >> PS: Even this is kinda curious because it throws the Exception after the >> second time it''s called, not the first one. Haven''t gone that deep yet. >> >> Regards. >> >> Edgar J. Suarez > > > >-- Cheers! - Pratik http://m.onkey.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Oh yes indeed. Thanks. Edgar J. Suarez On Oct 16, 4:24 pm, Pratik <pratikn...@gmail.com> wrote:> Hey Edgar, > > Doeshttp://github.com/rails/rails/commit/95c609357e78106e9673931d3f60d8ff...> fix it for you ? > > Thanks. > > On Thu, Oct 16, 2008 at 11:03 PM, Edgar J. Suárez <edgar...@gmail.com>wrote:> > > > > Sorry for the commit link, it is: > > >http://github.com/rails/rails/commit/517bc500ed95a84fd2aadff34fdc14cb... > > > / introduced the new method proxy_respond_to?... > > > Edgar J. Suarez > > > On Oct 16, 3:57 pm, "Edgar J. Suárez" <edgar...@gmail.com> wrote: > > >> Commithttp://github.com/rails/rails/commit/517bc500ed95a84fd2aadff34fdc14cb...> >> the new method proxy_respond_to?, but it has a bug. > > >> Suppose the following case (it''s using will_paginate plugin) > > >> class User < ActiveRecord::Base > >> has_many :articles > >> end > > >> Then you call: > > >> u = User.first > >> u.articles # => [some articles...] > >> u.articles # => > >> ArgumentError: wrong number of arguments (2 for 1) > >> from > >>.../activerecord/lib/active_record/associations/association_proxy.rb:78:in> >> `proxy_respond_to?'' > >> from > >>.../activerecord/lib/active_record/associations/association_proxy.rb:78:in> >> `respond_to?'' > >> from > >> .../vendor/plugins/will_paginate/lib/will_paginate/finder.rb:155:in > >> `respond_to?'' > >> from .../activerecord/lib/active_record/associations.rb:1287:in > >> `articles'' > >> from (irb):3 > > >> As you can see, the bug is caused in the will_paginate plugin becauseit> >> pass two params to the super respond_to? > > >> def respond_to?(method, include_priv = false) #:nodoc: > >> case method.to_sym > >> when :paginate, :paginate_by_sql > >> true > >> else > >> super(method.to_s.sub(/^paginate/, ''find''), include_priv) > >> end > >> end > > >> So the fix should be adding an extra param to proxy_respond_to? > > >> def proxy_respond_to?(method, include_priv = false) > >> super || @reflection.klass.respond_to?(method, include_priv) > >> end > > >> How could I test this to submit a patch? > > >> PS: Even this is kinda curious because it throws the Exception afterthe> >> second time it''s called, not the first one. Haven''t gone that deep yet. > > >> Regards. > > >> Edgar J. Suarez > > -- > Cheers! > - Pratikhttp://m.onkey.org--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
У Чцв, 16/10/2008 у 15:57 -0500, Edgar J. Suárez піша:> Commit > http://github.com/rails/rails/commit/517bc500ed95a84fd2aadff34fdc14cb7965bc6b introduced the new method proxy_respond_to?, but it has a bug. >...> How could I test this to submit a patch?Just check that association proxy understands #respond_to? with two arguments. This test will and the fix is trivial. BTW. I may be wrong, but it seems that people who contribute & accept patches somehow started to think less about trivial corner cases like this one. Is it false sence of safety caused by wider introduction of unit testing ? -- Aliaksey Kandratsenka <alkondratenko@gmail.com> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On Fri, Oct 17, 2008 at 8:09 AM, Aliaksey Kandratsenka <alkondratenko@gmail.com> wrote:> > BTW. I may be wrong, but it seems that people who contribute & accept > patches somehow started to think less about trivial corner cases like > this one. Is it false sence of safety caused by wider introduction of > unit testing ? >Sorry I don''t follow you ?> -- > Aliaksey Kandratsenka <alkondratenko@gmail.com> > > > > >-- Cheers! - Pratik http://m.onkey.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
У Пят, 17/10/2008 у 08:20 +0200, Pratik піша:> On Fri, Oct 17, 2008 at 8:09 AM, Aliaksey Kandratsenka > <alkondratenko@gmail.com> wrote: > > > > BTW. I may be wrong, but it seems that people who contribute & accept > > patches somehow started to think less about trivial corner cases like > > this one. Is it false sence of safety caused by wider introduction of > > unit testing ? > > > > Sorry I don''t follow you ?I may be wrong but it seems that similar trivial bugs started to appear more often then in the past. My guess is that people write failing test (which never covers all corner cases) and than simply write enough of code to make this test pass. -- Aliaksey Kandratsenka <alkondratenko@gmail.com> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---