Mik
Mik

Reputation: 1703

Rails4 scope with parameters

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 }

Upvotes: 3

Views: 3111

Answers (1)

campino star
campino star

Reputation: 106

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

this should work

Upvotes: 9

Related Questions