Maybe first in model,create find way function.the sql string looks likely
not complicated in my view.
use condition.blow find doc is in rails 2.3.x manule

   - :joins - Either an SQL fragment for additional joins like “LEFT JOIN
   comments ON comments.post_id = id” (rarely needed), named associations in
   the same form used for the :include option, which will perform an INNER
   JOIN on the associated table(s), or an array containing a mixture of both
   strings and named associations. If the value is a string, then the records
   will be returned read-only since they will have attributes that do not
   correspond to the table’s columns. Pass :readonly => false to override.
   - :include - Names associations that should be loaded alongside. The
   symbols named refer to already defined associations. See eager loading under
   Associations.

i think you should use include to implement your request.


2010/3/3 Webdesign Porto <[email protected]>

> SELECT profiles.*, friendships.updated_at AS friendship_updated_at,
> friendships.profile_id, friendships.friend_id, friendships.accepted AS
> friendship_accepted, friendships.rejected AS friendship_rejected FROM
> `profiles` INNER JOIN `friendships` ON `profiles`.id =
> `friendships`.profile_id WHERE (((`friendships`.profile_id = 1) OR
> (`friendships`.friend_id = 1)) AND ((`friendships`.`accepted` = 0)))
> ORDER BY friendships.updated_at LIMIT 0, 10
>
> more or less, this is the query. How do I make it a has many with
> belongs_to?
> I really dont know how to do it.. :s im working on it for 3-4 days...
> and still no answer. I dont use to ask for help in forums, but now... i
> really need some help here.
>
> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>


-- 
tommy xiao
E-mail: xiaods(AT)gmail.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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to