Topic: refactoring with a Ruby block
I've developed a billable hours tracking system for my company and in it I have a controller with three different actions that carry out a similar iterative statement:
projects = Project.find_all(:order => "name")
projects.each do |project|
hours = get_hours_for_project_between_dates(date_start, date_end, project.id)
# action specific code
I get the sense that I could abstract this with a Ruby block, but my attempts to do this haven't been very successful. So my questions are, is this abstractable with the help of a Ruby block; and if so, how would you go about doing it?
Last edited by elliotlarson (2007-05-08 04:47:19)