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

scope with a proc which return nil should still be chainable

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.1.3
    • Affects Version/s: None
    • Component/s: None
    • None

      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}
      

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

              Created:
              Updated:
              Resolved: