Skip to content

Instantly share code, notes, and snippets.

@rubypanther
Created February 20, 2012 07:32
Show Gist options
  • Save rubypanther/1868275 to your computer and use it in GitHub Desktop.
Save rubypanther/1868275 to your computer and use it in GitHub Desktop.
def last_activity_description(date, user_id)
user_activity = UserActivity.find(:first, :conditions => ["Date(updated_at) <= ? and user_id = ?", dat
e, user_id], :order => 'updated_at DESC')
user_activity.activity.description
end
# better
def last_activity(date, user_id)
UserActivity.find(:first, :conditions => ["Date(updated_at) <= ? and user_id = ?", dat
e, user_id], :order => 'updated_at DESC').activity
end
last_activity(date, user_id).description
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment