Monday, 26 August 2013

Is it possible to not repeat Rails ActiveRecord where conditions?

Is it possible to not repeat Rails ActiveRecord where conditions?

I have a a Rails ActiveRecord where that looks like this:
Things.where('blahs.user_id = ? OR user_id = ?', user.id, user.id)
I want user.id to be used in place of the two ?'s. Is there a way to not
repeat it like I've done?

No comments:

Post a Comment