diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-03-24 13:21:53 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-03-24 13:21:53 +0100 |
commit | 0f5bbb999c9770654613cb373070984dd785e855 (patch) | |
tree | 90c4dac78f605ea357868502da9607d6812a1a8b /app/models/concerns | |
parent | 7e58303a8da90b31f4179695283d3ac19dfb09d1 (diff) |
Pre-loading polymorphic associations for Atom feeds
Diffstat (limited to 'app/models/concerns')
-rw-r--r-- | app/models/concerns/paginable.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/concerns/paginable.rb b/app/models/concerns/paginable.rb new file mode 100644 index 000000000..54552ae3d --- /dev/null +++ b/app/models/concerns/paginable.rb @@ -0,0 +1,7 @@ +module Paginable + extend ActiveSupport::Concern + + included do + scope :paginate_by_max_id, -> (limit, max_id) { order('id desc').limit(limit).where(max_id.nil? ? '1=1' : ['id < ?', max_id]) } + end +end |