Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #8114 (closed defect: fixed)

Opened 2 years ago

Last modified 1 year ago

[PATCH] Minor Logic Bug in Routes [typo]

Reported by: spgarbet Assigned to: nseckar@gmail.com
Priority: low Milestone: 1.2.4
Component: ActionPack Version: edge
Severity: minor Keywords: tiny
Cc:

Description

A logic operator is mistakely written as a bit-wise operator in routing.rb. Right after the 'elsif' in the following code:

     def ensure_required_segments(segments)
        allow_optional = true
        segments.reverse_each do |segment|
          allow_optional &&= segment.optional?
          if !allow_optional && segment.optional?
            unless segment.optionality_implied?
              warn "Route segment \"#{segment.to_s}\" cannot be optional because it precedes a required segment. This segment will be required."
            end
            segment.is_optional = false
          elsif allow_optional & segment.respond_to?(:default) && segment.default
            # if a segment has a default, then it is optional
            segment.is_optional = true
          end
        end
      end
      

Should read as:

     def ensure_required_segments(segments)
        allow_optional = true
        segments.reverse_each do |segment|
          allow_optional &&= segment.optional?
          if !allow_optional && segment.optional?
            unless segment.optionality_implied?
              warn "Route segment \"#{segment.to_s}\" cannot be optional because it precedes a required segment. This segment will be required."
            end
            segment.is_optional = false
          elsif allow_optional && segment.respond_to?(:default) && segment.default
            # if a segment has a default, then it is optional
            segment.is_optional = true
          end
        end
      end

Attachments

ensure_required_segments-8114-patch.diff (0.7 kB) - added by watson on 05/05/07 21:58:49.
Now with patch

Change History

05/05/07 21:58:49 changed by watson

  • attachment ensure_required_segments-8114-patch.diff added.

Now with patch

05/05/07 22:06:14 changed by watson

  • summary changed from Minor Logic Bug in Routes [typo] to [PATCH] Minor Logic Bug in Routes [typo].

Due to the size of this patch, I haven't made any unittests or documentation. I hope that is ok.

08/25/07 06:47:23 changed by tarmo

  • keywords set to tiny.

No test required for this change.

+1

09/22/07 18:29:44 changed by david

  • owner changed from core to nseckar@gmail.com.

09/22/07 19:02:59 changed by ulysses

  • status changed from new to closed.
  • resolution set to fixed.

(In [7571]) Remove use of & logic operator. Closes #8114.