I have a class method on User, that returns applies a complicated select / join / order / limit to User, and returns the relation. It also applies a where(:admin => true) clause. Is it possible to remove this one particular where statement, if I have that relation object with me?
Something like
User.complex_stuff.without_where(:admin => true)
You could do something like this (
where_valuesholds eachwherequery; you’d have to tweak the SQL to match the exact output of:admin => trueon your system). Keep in mind this will only work if you haven’t actually executed the query yet (i.e. you haven’t called.allon it, or used its results in a view):However, I’d strongly recommend using Emily’s answer of restructuring the
complex_stuffmethod instead.