Re: [ruby-89] Re: relationship relationships

From: Matt N.
Sent on: Thursday, September 6, 2007 4:33 PM
really appreciate the email. i hate being bad at this.
here is the approach I am going to try tonight. 
 
#1: user has many relationships, relationship has many users
-I'm going to handle this with a join table "relationships_users" and the has_and_belongs_to_many declaration in class Relationship and User.
I'm not going to use :through.
 
#2: relationship has many expectations, and expectations are owned by a user. how to display expectations within a relationship sorted by user?
(note i changed, based on Chris comments from last night, "goals" to "expectations")
-Approach: Class Expectation belongs_to relationship,
Create column in database table "expectation" named "owned_by". When user adds an expectation, "owned_by" will be auto populated by signed-in user (sign in user is far in future).
 
-hope to do things like:

 

#who are the members of relationship 123?

  relationship = Relationship.find(123)

  members = relationship.users

 

#what relationships does Matt belong to?

  matt = User.find_by_name("matt")

  matt_relationships = matt.relationships

 

#what are the expectations for a user in relationship 123?

  relationship = Relationship.find(123)

  relationship_expectations = expectation.relationship

  and then order by expectation column owned_by

 

 

hope all is good. thanks again for pointers.

 

matt



On 9/5/07, jqr <[address removed]> wrote:
Matthew,

I looked through our "friendship" code to see if any of it is
applicable to your app. It's actually a bit more complex than I
remembered, and probably overkill for what you're doing. Our reasoning
for doing it that way was to reduce database size and queries, 1 row
instead of 3. Scaling is often sacrificing simplicity for speed.

What you're doing now(has_many :through) is probably more appropriate
for your application at this time.

Please feel free to ask any other questions you have.

Eli




--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ( [address removed])
This message was sent by jqr ([address removed]) from The Indianapolis Ruby & Rails Group.
To learn more about jqr, visit his/her member profile: http://ruby.meetup.com/89/members/4164108/
To unsubscribe or to update your mailing list settings, click here: http://www.meetup.com/account/?tab=comm

Meetup.com Customer Service: [address removed]
632 Broadway New York NY 10012 USA


Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy