dadah89 / active_record-comments

Add comments to ActiveRecord queries to see where they came from or what user caused them

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adds comments to your activerecord queries so you can seem where they came from or what user caused them.
Tested on Rails 4/5

ActiveRecord 6.0 introduces an API to annotate queries but doesn't provide a way to pass a block.

Install

gem install active_record-comments

Usage

require "active_record/comments"

# => SELECT ... /* user.rb:123 */
result = ActiveRecord::Comments.comment("user.rb:123") { User.where("x like y").count }

# => SELECT ... /* account cleanup initial */
result = ActiveRecord::Comments.comment("account cleanup") do
  ActiveRecord::Comments.comment("initial") { User.where("x like y").count }
end

Author

Michael Grosser
michael@grosser.it
License: MIT
Build Status

About

Add comments to ActiveRecord queries to see where they came from or what user caused them

License:MIT License


Languages

Language:Ruby 100.0%