LoadMore¶ ↑
A simple solution for performing load more queries with ActiveRecord
Installation¶ ↑
In your Gemfile:
gem 'load_more'
Then run
bundle install
Usage¶ ↑
Query¶ ↑
Article.load_more(last_load: params[:last_load_id]) Article.last_load(params:[last_load_id])
Configuring global default value¶ ↑
In config/initializers/load_more.rb
:
LoadMore.configure do |config| config.load_limit = 10 config.sort_column = :id config.sort_method = :desc end
The above is the default configuration.
Configuring default value for each model¶ ↑
In your model:
class Article < ActiveRecord::Base self.load_limit = 15 self.sort_column = :unique_id self.sort_method = :desc end
Configuring default values for each query¶ ↑
Article.load_more(load_limit: 20, sort_column: :sku, sort_method: :asc, last_load: 99)
License¶ ↑
This project rocks and uses MIT-LICENSE.