Forum: Ruby on Rails Appropriate method for no-op AR Query chain

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D5361c8ed0b0086cf48e43fb30db1c42?d=identicon&s=25 unknown (Guest)
on 2013-08-29 00:57
(Received via mailing list)
With Rails 3, we had a number of method-defined scopes along these
lines:

def self.with_name(name)
  if name.present?
    where(name: name)
  else
    scoped
  end
end

In Rails 4, `Model#scoped` is obviously deprecated and recommends
replacing
with `Model#all`. But it looks like `Relation#all` is deprecated as
well.
What's the "right" way to do this in Rails 4?

Looking at the code and docs, the best approach I've found is to use
`where(nil)` but that doesn't feel particularly idiomatic. Any better
approaches?

Thanks much,
Jeremy
This topic is locked and can not be replied to.