Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 0.44 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Associations of records of one table are in another
  2. Users: id, title
  3.  Infos: id, type, user_id_createdby, user_id_addressedto, text
  4.        
  5. Infos record: id: 1, type: "nextmeeting", user_id_createdby: 47, user_id_addressedto: 51,  text: "2011/01/13"
  6.        
  7. @users = User.joins("LEFT OUTER JOIN infos ON infos.user_id_createdby = users.id")
  8.        
  9. @users = User.joins("LEFT OUTER JOIN infos ON infos.user_id_createdby = users.id").order("infos.text DESC")