Created
September 24, 2010 00:48
-
-
Save jcbozonier/594689 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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