Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-2895

scope with a proc which return nil should still be chainable

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.1.3
    • Component/s: None
    • Labels:
      None

      Description

      just like activerecord, the scope should always be chainable, so we can write

      scope :before_date, ->(date) { where(:date.lt => date) if date}
      

      instead of

      scope :before_date, ->(date) { date ? where(:date.lt => date) : all}
      

        Attachments

          Activity

            People

            Assignee:
            durran Durran Jordan
            Reporter:
            niedhui dianhui
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: