0.0
No commit activity in last 3 years
No release in over 3 years
Just another scope to fetch the latest record with specified group.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 4.2.0
 Project Readme

GroupedLatest

Gem Version Code Climate Test Coverage Circle CI

GroupedLatest is just another scope to get the latest record from each group.

Requirement

  • Rails 4.2

Installation

# Gemfile
gem 'grouped_latest'

Usage

# app/models/post.rb
class Post < ActiveRecord::Base
  belongs_to :user
  belongs_to :category
  include GroupedLatest
end

$ rails c
> User.first.post.grouped_latest(:category_id)

Configuration

Post.latest_column = :id
Post.latest_strategy = :gl_arel_in

Strategies

WIP. I'm looking for the fastest logic.

$ rake test BENCH=1
Strategy        Average
gl_arel_in      0.13105687065399252ms
gl_arel_exists  0.13757433084538206ms
gl_array_in     11.309650258132024ms

Licence

This project rocks and uses MIT-LICENSE.

Author

@tnantoka