I have a problem I find difficult to search the web for an answer…
I have in my Ruby On Rails two models: User and Donation.
I want that a Relation has two user: user1 gives 10$ to user2.
This is what I came with:
class Donation < ActiveRecord::Base
attr_accessible :description, :value, :from_user_id, :to_user_id
def from_user
User.find(from_user_id)
end
def to_user
User.find(to_user_id)
end
end
But I would like to use relationships… Do you know the best way of doing this?
Thanks a lot 🙂
Relations are nothing special… well, okay, they are now, but this essentially constructs the appropriate sql. I think. Haven’t tried it.