Query problem

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

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

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
Stijn

Please 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