Skip to content

Change unless + else into if + else #6181

Closed
wants to merge 1 commit into from

2 participants

@carlosantoniodasilva carlosantoniodasilva commented on the diff May 6, 2012
actionpack/lib/action_view/helpers/date_helper.rb
@@ -66,12 +66,12 @@ module DateHelper
# distance_of_time_in_words(Time.now, Time.now) # => less than a minute
#
def distance_of_time_in_words(from_time, to_time = 0, include_seconds_or_options = {}, options = {})
- unless include_seconds_or_options.is_a?(Hash)
+ if !include_seconds_or_options.is_a?(Hash)
+ options = include_seconds_or_options
+ else
@carlosantoniodasilva
Ruby on Rails member

Sorry but this condition is wrong, the change inverts the logic. It should be something like:

if include_seconds_or_options.is_a?(Hash)
  options = include_seconds_or_options
else
  # ... warn and set option
end

Please make sure you run the tests to make sure everything is ok. Thanks!

@shaliko
shaliko added a note May 6, 2012

Yes, I was wrong. Closed the pull request. I wil fix it and make a new pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@shaliko shaliko closed this May 6, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.