Brynjolfur Thorvardsson wrote in post #1037995:

> @var1 = @friends.where(<select 1>)
> @var2 = @friends.where(<select 2>)
>
> @friendsfound = @var1 + @var2


tmp1 = Friendships.includes(:users).select("uid1 as user_id", 
status).where("uid2 = (?)", @user.id)
tmp2 = Friendships.includes(:users).select("uid2 as user_id", 
status).where("uid1 = (?)", @user.id)
@friends = tmp1 + tmp2

Tested, it works, but the only problem is ordering.

How to order:

.order("FIELD( friendships.status, 'lover', 'best friend', 'partner', 
'enemy' ), users.name")

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to