ruby on rails - moving rails2 to 4 and getting error - undefined method `with_scope' -
how replace query in rails4.1.9
auditarea.send(query_options[:include_retired] ? :with_exclusive_scope : :with_scope) { # stuff }
getting error undefined method `with_scope' .
the with_scope
called scoping
in newer rails versions. with_exclusive_scope
should unscoped
. both methods accept block code should work ok them.
see docs scoping
, unscoped
more info.
update: scoping
method not work if called on class itself. has called on scope (as opposed unscoped
works on bare model class). first add "harmless" scope all
(which selects records , behaves same way bare model class auditarea
) select both variants of send
work:
auditarea.all.send(query_options[:include_retired] ? :unscoped : :scoping) { # ... }
Comments
Post a Comment