Skip to content

Instantly share code, notes, and snippets.

@harley
Created October 3, 2009 20:51
Show Gist options
  • Save harley/200858 to your computer and use it in GitHub Desktop.
Save harley/200858 to your computer and use it in GitHub Desktop.
# All is good, just a tiny suggestion:
# app/controllers/dashboard_controller.rb: line 18
# Instead of:
@watched_objects = current_user.user_config.watched_data_objects.split(", ").map{|id| DataObject.find(id)}.flatten.group_by(&:data_type)
# Taking of .find syntax accepting list if id's, consider finding them all at once (please test it first)
# also .flatten is not needed)
DataObject.find(current_user.user_config.watched_data_objects.split(", ")).group_by(&:data_tytpe)
# also, it's normally OK to separate out to two lines so it's clearer to read
data_object_ids = current_user.user_config.watched_data_objects.split(", ")
@watched_objects = DataObject.find(data_object_ids).group_by(&:data_type)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment