0.0
No commit activity in last 3 years
No release in over 3 years
Count active record instantiations and report them to the log
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0
>= 0

Runtime

 Project Readme

BirthControl

Count active record instantiations and report them to the log.

Build Status

Coderwall Endorse

Installation

Add this line to your application's Gemfile:

gem 'birth_control', groups: [:development]

And then execute:

$ bundle

After bundling you'll need to enable the logging by putting this line into your development environment:

BirthControl.enable = true

Usage

Two new reports will be logged into your rails log:

  1. The class instantiation report - count all active record objects by class and in total
  2. Duplication report - reveals where active record objects were loaded more than once

Example reports:

This example show the result of a project detail page. You can see, that there were 5 project instantiations but always the same project. The first two may be necassary, but the later 3 could have been avoided.

*** [BirthControl] Class instantiation overview ***
    5 Projects
   20 ProjectPictures
    2 Users
    1 Countries
    3 BlogPosts
   30 Total

*** [BirthControl] Duplicate instantiation detected ***

Project(42) - 5 times
  1. app/controllers/projects_controller.rb:27:in `load_project_for_caching'
  2. app/controllers/projects_controller.rb:13:in `show'
  3. app/views/projects/_blog_post.html.slim:3:in `...'
  4. app/views/projects/_blog_post.html.slim:3:in `...'
  5. app/views/projects/_blog_post.html.slim:3:in `...'

Contributing

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

Changelog

0.0.1 (2013-11-16)

  • Initial import, basic reports