Project

preload

0.01
Low commit activity in last 3 years
A long-lived project that still receives updates
A better API for ActiveRecord eager loading
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 5.2, < 7.2
 Project Readme

Preload Build Status

Allows you to split your ActiveRecord find calls and your eager loading decisions.

Installation

gem install preload

Usage

Now in your controller you don't have to know which associations should be eager loaded because your views need them.

In your controller:

def index
  @posts = blog.posts.order('created_at DESC')
end

in your view:

  <% @posts.pre_load(:comments) %>
  ... render posts and their comments ...

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request