USER has_many categories CATEGORY belongs_to user has_many notes NOTES belongs_to category this is breaking.. @userCategories = Category.find(:all, :conditions => "user_id = 1", :include => :notes) yes, user_id is a column in my category table....thanks! -- 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 -~----------~----~----~----~------~----~------~--~---
What is the error message given and the SQL generated (You can find the SQL from the log) -Zach On Apr 28, 3:26 pm, mixplate <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> USER > has_many categories > > CATEGORY > belongs_to user > has_many notes > > NOTES > belongs_to category > > this is breaking.. > > @userCategories = Category.find(:all, :conditions => "user_id = 1", > :include => :notes) > > yes, user_id is a column in my category table....thanks! > > -- > Posted viahttp://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 Zach, Thanks for the reply...i found my careless error. there ww a null value in my db that was causing the error! -- 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 there, I''m actually wondering why you''re finding the categories that belong to a given user in the manner that you''ve shown us. You''ve gone through all that trouble to define your user -> category relationship why not use it? user = User.find(1) @userCategories = user.categories I see you''re prefetching notes as well so you can add that to your relationship declaration if you really need them. Anyway, not saying your usage isn''t for good reason but given the context it sorta jumps out at me that you''re not using the association for what''s essentially the same exact query as you''re building by hand. Best regards, -Michael http://javathehutt.blogspot.com On Apr 28, 2007, at 12:26 PM, mixplate wrote:> > USER > has_many categories > > CATEGORY > belongs_to user > has_many notes > > NOTES > belongs_to category > > > this is breaking.. > > @userCategories = Category.find(:all, :conditions => "user_id = 1", > :include => :notes) > > > yes, user_id is a column in my category table....thanks! > > -- > 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 -~----------~----~----~----~------~----~------~--~---