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 }

1

1 Answer 1

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

this should work

Sign up to request clarification or add additional context in comments.

1 Comment

Why does adding a space between -> and (id) break?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.