Skip to content

Instantly share code, notes, and snippets.

@kellydunn
Created November 19, 2010 23:43
Show Gist options
  • Save kellydunn/707422 to your computer and use it in GitHub Desktop.
Save kellydunn/707422 to your computer and use it in GitHub Desktop.
gotta get that board board board
def solve
@guess = Board.from_hash(params[:solution])
if @board.partial_solution?(@guess)
current_user.current_user_game_board.score!
flash[:notice] = "Your answer matched the solution!"
else
current_user.current_user_game_board.missed_guess
flash[:alert] = "Your answer was wrong!"
end
current_user.next_board!
destination = if !current_user.in_game?
done_game_path(@game)
else
game_board_path(current_user.current_game,
current_user.current_board)
end
respond_to do |format|
format.html { redirect_to dest }
format.json {
render :json => { :correct => @board.partial_solution?(@guess), :destination => destination }
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment