On 3 March 2010 04:41, Webdesign Porto <[email protected]> wrote:
> 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.

Don't think about the query first, think about what your models are
and how they are related.  Then decide what information you need from
the db in terms of those relationships not in terms of SQL.  Using
rails you should only rarely need to worry about SQL, that is a major
part of the magic of rails.

Colin

-- 
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