Skip to content

Instantly share code, notes, and snippets.

@reagent
Forked from efatsi/past_orders.rb
Created September 12, 2012 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reagent/3709592 to your computer and use it in GitHub Desktop.
Save reagent/3709592 to your computer and use it in GitHub Desktop.
methodology comparison
def find_suggestions_for(restaurant)
past_orders = []
orders.each {|o| past_orders << o if o.restaurant == restaurant }
past_orders
end
def find_suggestions_for(restaurant)
orders.inject([]) do |result, order|
result << order if order.restaurant == restaurant
result
end
end
def find_suggestions_for(restaurant)
orders.select {|o| o.restaurant == restaurant}
end
def find_suggestions_for(restaurant)
orders.joins(:meal).where('meals.restaurant_id' => restaurant.id)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment