3

I somehow cannot find any place in the rails documentation about how to put some params into a named scope, f.e. something like this

scope :by_id, -> { where :id = id }

Mik
  • 1,705
  • 1
  • 14
  • 26
  • possible duplicate of [scopes with lambda and arguments in Rails 4 style?](http://stackoverflow.com/questions/16588077/scopes-with-lambda-and-arguments-in-rails-4-style) – Abhi Jun 11 '15 at 07:20

1 Answers1

9
scope :by_id, ->(id) {where (:id => id)}

this should work

campino star
  • 106
  • 1