In Hobo has_one :through thinks it's an Array
Reported by Betelgeuse | December 20th, 2010 @ 05:09 PM | in Hobo 1.0X
Given associations:
belongs_to :parent
has_one :parent_parent, :through => :parent
In this case we get:
>> t.parent_parent.class
=> ParentParent
>> t.parent_parent.is_a?(Array)
=> true
Faulty code found via debugger:
[31, 40] in /usr/local/lib/ruby/gems/1.8/gems/hobo-1.0.2/lib/active_record/association_collection.rb
31 proxy_respond_to?(args) || Array.new.respond_to?(args)
32 end
33
34 # TODO: send this patch into Rails. There's no reason to load the collection just to find out it acts like an array.
35 def is_a?(klass)
=> 36 [].is_a?(klass)
37 end
38
39 def member_class
40 proxy_reflection.klass
Comments and changes to this ticket
-
Bryan Larsen January 13th, 2011 @ 05:27 PM
- Milestone set to Hobo 1.0X
- State changed from new to open
- Assigned user set to Bryan Larsen
- Milestone order changed from 197931 to 0
Interstingly, it appears that this problem occurs on Rails 2.3.10 but not on 2.3.5. EDIT: oops, ignore this comment, it was something else. The problem is more universal.
-
Bryan Larsen January 15th, 2011 @ 03:17 PM
(from [7e5333643a067f33e3acd42e3dc60274fa29021e]) [#888] remove optimization that breaks has_one on Rails 2.3.10 https://github.com/tablatom/hobo/commit/7e5333643a067f33e3acd42e3dc...
-
Bryan Larsen January 17th, 2011 @ 10:42 PM
- Milestone order changed from 10 to 0
(from [cbc01da61ecb3c739e7e4f4e95715f623d76d71f]) [#888] remove optimization that breaks has_one on Rails 2.3.10 https://github.com/tablatom/hobo/commit/cbc01da61ecb3c739e7e4f4e957...
-
Bryan Larsen January 18th, 2011 @ 03:02 PM
I did add a test to hte2/hobo-test for this condition. I know it's more work to port hte2 or hobo-test to Rails3 than to try this scenario on your own, but it would kill more birds with one stone. :)
-
Matt Jones February 16th, 2011 @ 05:04 PM
(from [24b4562b684e1370f55b5f4f0d04555a205a9dd9]) [#888] fix behavior for has_one without causing excessive loading https://github.com/tablatom/hobo/commit/24b4562b684e1370f55b5f4f0d0...
-
Matt Jones February 17th, 2011 @ 08:37 PM
(from [955f6753d17d1f930c1a4eaf36b18f08a78f6db0]) [#888] fix behavior for has_one without causing excessive loading https://github.com/tablatom/hobo/commit/955f6753d17d1f930c1a4eaf36b...
-
Matt Jones September 14th, 2011 @ 08:04 PM
(from [cbf7a2439f77dfa640863e6e429feeb97f19c38f]) [#888] fix handling of has_one and is_a https://github.com/tablatom/hobo/commit/cbf7a2439f77dfa640863e6e429...
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
People watching this ticket
Tags
Referenced by
- 888 In Hobo has_one :through thinks it's an Array (from [7e5333643a067f33e3acd42e3dc60274fa29021e]) [#888] ...
- 888 In Hobo has_one :through thinks it's an Array (from [cbc01da61ecb3c739e7e4f4e95715f623d76d71f]) [#888] ...
- 888 In Hobo has_one :through thinks it's an Array (from [24b4562b684e1370f55b5f4f0d04555a205a9dd9]) [#888] ...
- 888 In Hobo has_one :through thinks it's an Array (from [955f6753d17d1f930c1a4eaf36b18f08a78f6db0]) [#888] ...