Skip to content

Instantly share code, notes, and snippets.

@mrbrdo
Created April 2, 2011 23:07
Show Gist options
  • Save mrbrdo/899993 to your computer and use it in GitHub Desktop.
Save mrbrdo/899993 to your computer and use it in GitHub Desktop.
scope :get_professors, lambda {
all.map(&professor)
}
ruby-1.8.7-p334 :002 > Programme.first.professor_at_programmes.by_rating("ASC").includes(:professor).get_professors
=> []
ruby-1.8.7-p334 :003 > Programme.first.professor_at_programmes.by_rating("ASC").includes(:professor).map(&:professor)
=> [#<Professor id: 2, slug: "B", name: "B", surname: "B", created_at: "2011-04-02 21:52:01", updated_at: "2011-04-02 21:52:01">, #<Professor id: 3, slug: "C", name: "C", surname: "C", created_at: "2011-04-02 21:52:04", updated_at: "2011-04-02 21:52:04">, #<Professor id: 1, slug: "A", name: "A", surname: "A", created_at: "2011-04-02 21:51:57", updated_at: "2011-04-02 21:51:57">]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment