Hi guys,
I''m with a problem trying to use find_*
check example code here: http://rafb.net/p/1sZSvM83.html
So, the problem is, if I try to do
Task.find_all_by_project_id(u.projects) it doesnt work, but this
Task.find_all_by_project_id(u.projects.collect{|p| p.id}) works.
Any help?
-- 
Rafael Mueller
http://queroseragil.wordpress.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
> Task.find_all_by_project_id(u.projects) it doesnt work, but thisprojects contains an array with hashes which looks like: [{:id => 1, :name => ''me''}, {:id => 2, :name => ''you''}] rails can''t know which key in the hash to use (ok, it could be nice and default to id...)> Task.find_all_by_project_id(u.projects.collect{|p| p.id}) works.this collects all projects ids in an array like [1, 2] which rails can handle -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Thorsten, On Nov 20, 2007 1:51 PM, Thorsten Muller <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Task.find_all_by_project_id(u.projects) it doesnt work, but this > > projects contains an array with hashes which looks like: > [{:id => 1, :name => ''me''}, {:id => 2, :name => ''you''}] > > rails can''t know which key in the hash to use (ok, it could be > nice and default to id...)Actually, i think rails know wich one is the key, because the generated query is: "SELECT * FROM tasks WHERE (tasks.`project_id` = 3,4)" Rails got the right key, but he can''t identify thats an array, i think. Regards, -- Rafael Mueller http://queroseragil.wordpress.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---