Skip to content

Instantly share code, notes, and snippets.

@dhiemstra
Created April 11, 2012 12:54
Show Gist options
  • Save dhiemstra/2359132 to your computer and use it in GitHub Desktop.
Save dhiemstra/2359132 to your computer and use it in GitHub Desktop.
Mobile crap
# Public: Returns an optimized hash object for mobile representation of weekly activities.
#
# The returned hash would look like this {"Monday" => [schedule_items], "Tuesday" => [], ...}
def current_week_for_mobile
start = proxy_association.owner.local_time.beginning_of_week
end = proxy_association.owner.local_time.end_of_week
(start..end).inject({}) do |memo,day|
memo[Date::DAYNAMES[day.wday]] = ScheduleItem.where(date: day.to_date)
memo
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment