Skip to content

Commit

Permalink
Changing checks in controller and view from .class == to .is_a?
Browse files Browse the repository at this point in the history
  • Loading branch information
James Cash authored and James Cash committed Sep 21, 2009
1 parent 5edfe03 commit a434564
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/elections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def results
win_id, @num_spoiled = Results::Preferential.calculate_winner_preferential(@election)
if win_id == :spoiled
@winner = :spoiled
elsif win_id.class == Array
elsif win_id.is_a?(Array)
@winner = win_id.map { |id| @election.choices.find(id) }
else
@winner = @election.choices.find(win_id)
Expand Down
2 changes: 1 addition & 1 deletion app/views/elections/results.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

-if @winner == :spoiled
Election was spoiled
-elsif @winner.class == Array
-elsif @winner.is_a?(Array)
%h2= "Tie; Winners are #{@winner.map(&:text).to_sentence}"
-else
%h2= "Winner is: #{@winner.text}"

0 comments on commit a434564

Please sign in to comment.