Skip to content

Instantly share code, notes, and snippets.

@jcbozonier
Created September 24, 2010 00:48
Show Gist options
  • Save jcbozonier/594689 to your computer and use it in GitHub Desktop.
Save jcbozonier/594689 to your computer and use it in GitHub Desktop.
require 'date'
class ChoreAssignmentController < ApplicationController
def assign_todays_chore
@users_chore_list.provide_todays_chore_to this
end
def todays_chore_is chore
@assignment = chore
end
end
class ChoreList
def provide_todays_chore_to user
user.todays_chore_is the_first_random_chore_I_can_find
end
def the_first_random_chore_I_can_find
first_random_chore_found = @chore_list.where(:user_id => current_user.id, :date => today).first
first_random_chore_found ||= @chore_list.create(:user => current_user, :chore => Chore.random, :date => today)
first_random_chore_found
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment