Skip to main content
Grammatical and formatting fixes
Source Link
Chris Cirefice
  • 5.9k
  • 7
  • 49
  • 75
  1. Logic, okOK it might soundssound a bit weak for this but it would be logical to say that "i"I have a supplier who has an account with me, iI want to see all the entire account history of this supplier", so it makes sense for me to be able to access account history from supplier straightdirectly.

  2. Efficiency, this for me is the main reason iI would use :through:through, simply because this issues a join statement rather than calling supplier, and then account, and then account_history. noticed the number of database calls?

  • using :through:through, 1 call to get the supplier, 1 call to get account_history (rails automatically useduses :join:join to retrieve through account)

  • using normal association, 1 call to get supplier, 1 call to get account, and 1 call to get account_history

that'sThat's what iI think =) hope it helps!

  1. Logic, ok it might sounds a bit weak for this but it would be logical to say that "i have a supplier who has an account with me, i want to see all the account history of this supplier", so it makes sense for me to be able to access account history from supplier straight

  2. Efficiency, this for me is the main reason i would use :through, simply because this issues a join statement rather than calling supplier, and then account, and then account_history. noticed the number of database calls?

  • using :through, 1 call to get the supplier, 1 call to get account_history (rails automatically used :join to retrieve through account)

  • using normal association, 1 call to get supplier, 1 call to get account, and 1 call to get account_history

that's what i think =) hope it helps!

  1. Logic, OK it might sound a bit weak for this but it would be logical to say that "I have a supplier who has an account with me, I want to see the entire account history of this supplier", so it makes sense for me to be able to access account history from supplier directly.

  2. Efficiency, this for me is the main reason I would use :through, simply because this issues a join statement rather than calling supplier, and then account, and then account_history. noticed the number of database calls?

  • using :through, 1 call to get the supplier, 1 call to get account_history (rails automatically uses :join to retrieve through account)

  • using normal association, 1 call to get supplier, 1 call to get account, and 1 call to get account_history

That's what I think =) hope it helps!

Post Made Community Wiki
Source Link
Staelen
  • 7.9k
  • 5
  • 36
  • 30

  1. Logic, ok it might sounds a bit weak for this but it would be logical to say that "i have a supplier who has an account with me, i want to see all the account history of this supplier", so it makes sense for me to be able to access account history from supplier straight

  2. Efficiency, this for me is the main reason i would use :through, simply because this issues a join statement rather than calling supplier, and then account, and then account_history. noticed the number of database calls?

  • using :through, 1 call to get the supplier, 1 call to get account_history (rails automatically used :join to retrieve through account)

  • using normal association, 1 call to get supplier, 1 call to get account, and 1 call to get account_history

that's what i think =) hope it helps!