neufelni
2010-Jun-07 15:46 UTC
ActiveRecord.find - Association Not Found Error When Using Custom Joins
Hello, When calling the find method on one of my models, I am joining to several other table using the :joins parameter. Currently, the :joins parameter is being populated with an array of several associations. However, I need to add a custom join, but when I add a string with my custom join to the joins array, I get the following error: Association named '' INNER JOIN ... '' was not found; perhaps you misspelled it? According to the documentation found here: http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001777, the :joins parameter can contains "an array containing a mixture of both strings and named associations." That is exactly what I''m doing, so I''m not sure why I''m getting this error when trying to combing them. Any ideas why this error would occur? Thanks, neufelni -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2010-Jun-07 16:11 UTC
Re: ActiveRecord.find - Association Not Found Error When Using Custom Joins
On Jun 7, 4:46 pm, neufelni <neufe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> According to the documentation found here:http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001777, > the :joins parameter can contains "an array containing a mixture of > both strings and named associations." That is exactly what I''m doing, > so I''m not sure why I''m getting this error when trying to combing > them. > > Any ideas why this error would occur? >A cursory look at the code suggests that nothing is being done to handle the case of a mixture of strings & named associations. Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ar Chron
2010-Jun-07 16:13 UTC
Re: ActiveRecord.find - Association Not Found Error When Using Custom Joins
Well, example code, yours to be exact, would help in diagnosing the issue... Otherwise, it''s simply ''you must have implemented something incorrectly'' -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
neufelni
2010-Jun-08 13:06 UTC
Re: ActiveRecord.find - Association Not Found Error When Using Custom Joins
It looks like you are right Fred, the code doesn''t actually handle a mixture of strings and associations. I found the following patch to fix the problem: http://groups.google.ca/group/rubyonrails-core/browse_thread/thread/50339b16ca736500 Thanks, neufelni On Jun 7, 12:11 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jun 7, 4:46 pm, neufelni <neufe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > According to the documentation found here:http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001777, > > the :joins parameter can contains "an array containing a mixture of > > both strings and named associations." That is exactly what I''m doing, > > so I''m not sure why I''m getting this error when trying to combing > > them. > > > Any ideas why this error would occur? > > A cursory look at the code suggests that nothing is being done to > handle the case of a mixture of strings & named associations. > > Fred-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.