I have named_scope which is reused in multiple ActiveRecord models. For example:
named_scope :limit, lambda {|limit| {:limit => limit}}
What is the best practice to extract this code to be shared across models. Is it possible to extract it to a module or should I rather reopen ActiveRecord::Base class?
User.limit(1)
works, but the second call to limit here raises an error:users=User.limit(5); users.limit(1)
. Any solution for the instance level? – Grapery