Hi all, I have users (has many) accounts I want to show all users and the account (if he has one) of a certain type. How can I query all users and if the user has a specific account, the account. If I do :conditions => :accounts.type = ''type'' I only get the users with an account. I also want the users with an account. Someone has an idea how to solve this? Thanks Stijn --~--~---------~--~----~------------~-------~--~----~ 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 all, I have users (has many) accounts I want to show all users and the account (if he has one) of a certain type. How can I query all users and if the user has a specific account, the account. If I do :conditions => :accounts.type = ''type'' I only get the users with an account. I also want the users without an account. Someone has an idea how to solve this? Thanks Stijn --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Tarscher wrote:> I have users (has many) accounts > > I want to show all users and the account (if he has one) of a certain > type. > > How can I query all users and if the user has a specific account, the > account. If I do :conditions => :accounts.type = ''type'' I only get the > users with an account. I also want the users with an account.Sounds like you want to do the account selection in Rails after the fact. Something like: Users.find(:all).each do |user| user.show account = user.account account.show if account && account.type == whaka_whaka end -- 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 -~----------~----~----~----~------~----~------~--~---
Tarscher wrote:> Hi all, > > I have users (has many) accounts > > I want to show all users and the account (if he has one) of a certain > type. > > How can I query all users and if the user has a specific account, the > account. If I do :conditions => :accounts.type = ''type'' I only get the > users with an account. I also want the users with an account. > > Someone has an idea how to solve this? > > Thanks > StijnPlease read the last line that you wrote and read it back to yourself and see if it makes any sense to you.. "If i do .................. I only get the users with and account, I also want the users with an account" If you rephrase, I think we will be able to serve you better.. Also, please submit the associations exactly as you have them specified in your models.. ilan -- 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 -~----------~----~----~----~------~----~------~--~---