flyerhzm / bullet Goto Github PK
View Code? Open in Web Editor NEWhelp to kill N+1 queries and unused eager loading
License: MIT License
help to kill N+1 queries and unused eager loading
License: MIT License
I'm running into an issue with deep eager loading. If I do this:
:include => [:hotel, :extras]
bullet tells me that I need to eager load locations for Hotel (it says I need ":include => [:location]" for Hotel). If I then do:
:include => [{:hotel => :location}, :extras]
then bullet tells me that I have an unused eager load (for the above, although it doesn't show the deep eager load part for the hotel, just says, ":include => [:extras, :hotel]").
I'm wondering if deep eager loading is not handled well in Bullet or if I'm doing something wrong, or? I did see the one other issue saying that eager loading was not put into the log, but I'm unclear if that's related or different for default_scopes, etc.
Hi, I'm trying to make bullet work, but unfortunately it completely freezes the app. Nothing is logged on the console, I only see a query in development.log (the first one) and after nothing else. If I remove bullet everything returns to normality.
I'm using rails 2.3.5 on ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin10]. I've tried with rack 1.0.1 and rack 1.1.0. I disabled the browser cache and tried both firefox and safari.
It just loads forever - not even a timeout. Growl seems to start correctly.
What am I doing wrong ?
WIth Bullet installed in Rails 2.2 application it failed on every request complaining about missing perform_bullet_out_of_channel_notifications method call from action_controller2.rb.
After changing to perform_out_of_channel_notifications it started working.
Reproduced with 2.0.1 gem
In my Rails 2.3.11 site we were trying to move to ruby 1.9.2p136 from REE and (much to our surprise) everything was much slower. After some debugging I found that just calling a Rails dynamic finder (Model.find_by_some_column) in a loop created 20 million more strings than it did in REE. After removing Bullet I could run my test script in 1/6 the time because I spent less time in garbage collection.
ERROR: While executing gem ... (ArgumentError)
Illformed requirement ["v2.0.0.beta.2"]
My Gemfile had following line:
gem "bullet", ">= 2.0.0"
(I know this is more bundler problem, but could you change naming scheme for versions?)
With Bullet enabled, even if all alerts are off, view html contents are spilling into rails logs. This makes it hard to wade through the log to find Bullet messages for exact line number messages. Probably just an errant puts statement somewhere.
config.after_initialize do
Bullet.enable = true
Bullet.alert = false
Bullet.bullet_logger = false
Bullet.console = false
Bullet.growl = false
Bullet.rails_logger = false
Bullet.disable_browser_cache = false
end
This might be an issue on my local box, but after installing bullet I get this error anytime I run rake:
rake aborted!
uninitialized constant Rails::Initializer::Bullet
$PATH/Rakefile:10
I have the config files in my development.rb file copy/pasted directly from the readme. Though Bullet works fine and the Rails app works fine. I only get that error when running Rake. Any ideas?
Using Rails 2.3.5 with Bullet 2.1.0, I have a model like this
MainModel < ActiveRecord::Base
belongs_to :sub_model
named_scope :my_finder, lambda {
{:include => :sub_model, :conditions => ["...."] }
}
end
SubModel < ActiveRecord::Base
belongs_to :some_data
end
SomeData < ActiveRecord::Base
end
And my list is something like
results = MainModel.my_finder
results.each do |result|
result.sub_model.some_data
end
Bullet now says
N+1 Query detected
SubModel => [:some_data]
Add to your finder: :include => [:some_data]
First and second line are correct. But in the third line, Bullet should suggest :include => {:sub_model => :some_data}
If I add the ladder one, the N+1 Queries are gone. But Bullet complains
Unused Eager Loading detected
SubModel => [:some_data]
Remove from your finder: :include => [:some_data]
I have a Rails 3 app where I am adding ActionDispatch::Static middlware to server some additional static content. This middleware is actually added by a separate Rails engine, after the Bullet middleware is added to the stack (I can print out the stack after my engine adds its ActionDispatch::Static).
When GETing static files from this instance of ActionDispatch::Static, I get the error:
undefined method `body' for #<Rack::File:0x1049060f0>
/gems/bullet-2.3.1/lib/bullet/rack.rb:31:in `empty?'
/gems/bullet-2.3.1/lib/bullet/rack.rb:12:in `call'
It seems that since Rack::File is not an Array
(but does respond to #each
as the Rack spec mandates), Bullet assumes it responds to the #body
method.
I'm getting this after everything was installed:
=> Booting Mongrel
=> Rails 2.3.4 application starting on http://0.0.0.0:3000
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:585:in `to_constant_name': Anonymous modules have no name to be referenced by (ArgumentError)
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:391:in `qualified_name_for'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:104:in `const_missing'
from /Library/Ruby/Gems/1.8/gems/flyerhzm-bullet-1.4.0/lib/bullet.rb:9:in `enable='
from /Users/kieran/Work/wfcc_rosters/config/environments/development.rb:26:in `load_environment'
I've set it up exactly as the README describes. Line 26 of config/environments/development.rb is
Bullet.enable = true
When i try and bundle install
bullet within my app i am unable to relaunch my server. Im getting the following turning up in my log file:
Invalid gemspec in [/Users/peterroome/.rvm/gems/ruby-1.9.2-p136/specifications/uniform_notifier-1.0.2.gemspec]: Illformed requirement ["#<Syck::DefaultKey:0x00000100d16ce8> 3.0"]
My Gemfile looks like this:
source :rubygems
gem 'rails', '3.1.1'
gem "authlogic"
gem 'nokogiri'
gem 'rockstar'
gem 'delayed_job', '2.1.2'
gem 'hirefireapp'
gem 'ruby-mp3info', :require => 'mp3info'
gem 'xml-simple'
gem 'httparty'
gem 'paperclip'
gem "aws-sdk"
gem 'thin'
gem 'unicorn'
gem 'pg'
gem 'redis', '2.2.2'
gem 'kaminari'
gem 'sendgrid'
gem 'asset_sync'
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', " ~> 3.1.0"
gem 'uglifier'
end
gem 'jquery-rails'
gem 'exceptional'
gem 'yajl-ruby'
gem 'ruby-prof'
gem "bullet", :group => "development"
I've tried installing bullet via bundler and via gem install and i've also tried installing uniform_notifier via both of these methods too. None of which seems to help.
When i do bundle show bullet
i get:
Invalid gemspec in [/Users/peterroome/.rvm/gems/ruby-1.9.2-p136/specifications/uniform_notifier-1.0.2.gemspec]: Illformed requirement ["#<Syck::DefaultKey:0x00000100c8f3b0> 3.0"] Invalid gemspec in [/Users/peterroome/.rvm/gems/ruby-1.9.2-p136/specifications/uniform_notifier-1.0.2.gemspec]: Illformed requirement ["#<Syck::DefaultKey:0x00000100c8f3b0> 3.0"] Could not find uniform_notifier-1.0.2 in any of the sources
So i suspect the problem is likely with uniform_notifier but as i said, trying to install this gem prior to bullet hasn't helped.
Have you got any suggestions please?
EDIT: I've just added bullet to a new Rails 3.2 gemfile and run bundle install
and i'm having the same problem there too.
Hello, tried to use bullet on a rails 3.1rc4 application with the following settings in config/environments/development.rb :
config.after_initialize do
Bullet.enable = true
Bullet.alert = true
Bullet.bullet_logger = true
Bullet.console = true
Bullet.growl = false
Bullet.rails_logger = true
Bullet.disable_browser_cache = true
end
And then the application wouldn't start because of this error :
.rvm/gems/ruby-1.9.2-p180@rails_3_1rc4/gems/bullet-2.0.1/lib/bullet/active_record2.rb:7:in alias_method': undefined method
find_every' for class `Class' (NameError)
give user a suggestion to use counter cache
add method caller stack to log file so that user can find the codes quickly
I got this during a migration. I worked around it by removing bullet from my configuration file during the migration.
undefined method `add' for nil:NilClass vendor/rails/activesupport/lib/active_support/whiny_nil.rb:52:in `method_missing' /Library/Ruby/Gems/1.8/gems/bullet-2.0.0.beta.3/lib/bullet/detector/n_plus_one_query.rb:21:in `create_notification' /Library/Ruby/Gems/1.8/gems/bullet-2.0.0.beta.3/lib/bullet/detector/n_plus_one_query.rb:14:in `call_association' /Library/Ruby/Gems/1.8/gems/bullet-2.0.0.beta.3/lib/bullet/active_record2.rb:84:in `load_target' vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:212:in `method_missing'
I am on version '2.0.0.beta.3'
Thanks for the awesome gem.
It would be nice to selectively activate Bullet when you start a server with a flag. The other contributor on my projects is a designer and he gets annoyed with all the Growl notifications and having to disable his browser cache to avoid the nil.include? error. It would be nice to have an option such as script/server --bullet
that allows me to enable Bullet when I want to use it.
Hi,
I'm running Rails 2.3.3, and I just upgraded the bullet gem from 1.4.1 to 1.5.4, and I get the following when I start the app:
/config/environments/development.rb:27:in load_environment': undefined method
alert=' for Bullet::Association:Class (NoMethodError)
Reverting to version 1.4.1 (the previous I had) fixes this.
Thoughts?
Thanks,
Mike
Is there anyway Bullet could output the line number of the finder that needs to be modified? I've taken over a convoluted app, and am actually having trouble finding the finders Bullet is telling me to modify.
I'd like to see bullet run when i run my functional/integration tests, just instead of popping growl notification have it save notifications to a log on @config/bullet.log@ or something.
I've got a simple model/association set up:
class Computer < ActiveRecord::Base
belongs_to :lifecycle_status
end
class LifecycleStatus < ActiveRecord::Base
has_many :computers, :dependent => :nullify
end
In my Computer's view I have the following:
<%= @computer.lifecycle_status %>
With Bullet disabled, it works fine, just printing out an empty string.
With Bullet enabled I get the following:
undefined method `id' for nil:NilClass
Even attempting to check if @computer.lifecycle_status.nil?
causes the error, so I can't avoid it.
Am I doing something wrong or is there a way to prevent Bullet from trying to resolve null associations?
This is the error:
.rvm/gems/ruby-1.9.2-p290@execuzone/bundler/gems/bullet-662e26635410/lib/bullet/active_record3.rb:23:in `enable': uninitialized constant ActiveRecord::AssociationPreload (NameError)
When RubyInline is included, it injects #inline class function. This interferes with JavascriptConsole#inline and JavascriptAlert#inline. So instead, RubyInline's #inline function was called and errors out.
Within the Growl section of your documentation, you state the following:
Bullet.growl_password = { :password => 'growl password' }
...but should be the following:
Bullet.growl = { :password => 'growl password' }
Using Bullet 2.0.0 beta 2, Rails 3 beta 3 and Devise 1.1rc1, bullet causes an exception:
undefined method `body' for #Array:0xb27580c
in lib/bulletware.rb:30.
Seems that the relevant response is an array but not empty, so ruby stumbles over
(response.is_a?(Array) && response.empty?) || !response.body.is_a?(String) || response.body.empty?
Is it possible to turn bullet off for part of an action I don't want any bullet logs for? The part in question is a rather complicated sql structure (sti combined with polymorphism structured in a tree with ancestry) and no matter what suggestion of bullet I follow, it either wants me to remove one include and add another, and when I do that it suggests vice-versa. I logged the SQL commands and found the better :include option of both variants and now I want to do something like:
silence_bullet do
my_complicated_finder :include => :xyz
end
This is the snippet that freezes us up when using bullet, but works fine without bullet.
@Assessment = Assessment.find(params[:id],
:include => [:demographic, :participant,
:sten_scores, :raw_scores,
{:responses => {:question => :question_choices}}])
This happens in my app when I have some caching going on and I'm rendering out the response body in an around or before filter.
This issue is caused by the fact that response.body is frozen at this point and cant be modified in the bullet middleware call method (to place in the javascript). The solution (for me) was to replace line 15 in bulletware.rb with the following;
response_body = (response.body.frozen? ? response.body : (response.body << Bullet.javascript_notification))
(i.e. check if frozen before modifying body) -- Obviously doing this means I only get the Growl notification message and NO javascript message. But its enough for me to see whats going on.
If I have this in my model:
default_scope :include=>{:foo=>:bar}
But I don't use the Bar model in the view, then I get an error:
undefined method `to_sym' for {:foo=>:bar}:Hash
on /plugins/bullet/lib/bullet/association.rb:84:in `log_bad_associations'
I use middleware which is introduced by rails 2.3. Try to support rails before version 2.3.
if resource not found, bullet will break the response
Bullet seems to be a bit overzealous about unused eager loading warnings. When i load through an association like this:
Category.find_by_name(params[:category_name], :include => {:submissions => :user}, :order => "id DESC")
Bullet seems to think that I don't need the submissions collection even though it is used in the view and also used to render a partial.
We have a chain of scopes on a model on which bullet chokes when evaluating check_unused_preload_associations. When this exception (due to calling flatten!) reaches the rack layer, we get an error page. This has led us to do the following patch, so that we do not have to disable bullet altogether. It could be complicated to isolate the lower-level crash, but at the rack level, we think allowing the exception to bubble up is bad form (logging would be better).
module Bullet
def self.notification?
Bullet::Detector::UnusedEagerAssociation.check_unused_preload_associations
notification_collector.notifications_present?
rescue
false
end
end
So I'm just trying out Bullet for the first time, and one of the warnings I get is this:
Unused Eager Loading in /blog
User => [:roles, "roles"]
Remove from your finder: :include => [:roles, :roles]
OK, so I do a search for User.
, which returns a few results, but none of them is including roles
. So then I do a search for :include => 'roles
(and various other ways of displaying it). The only result I get is for a named scope I have:
named_scope :bloggers, :include => 'roles', :joins => :posts, :conditions => ["roles.name IN ('Admin', 'Editor','Blogger') AND users.name <> 'Administrator'"]
It's ugly, but roles
is definitely being used here. So I'm unsure why Bullet is telling me to remove it? I tried a number of other parts of my site, and it seems in every area, almost all of the warnings Bullet throws are actually for named scopes. Am I misunderstanding something?
Nuff said.
Thanks for your work!
Seems to be failing in rails 3.2.1
config.after_initialize do
Bullet.enable = true
end
gives me:
/home/rio/.gem/ruby/1.9.2/gems/bullet-2.1.0/lib/bullet/active_record2.rb:8:in 'alias_method': undefined method 'find_every' for class 'Class' (NameError)
from /home/rio/.gem/ruby/1.9.2/gems/bullet-2.1.0/lib/bullet/active_record2.rb:8:in 'singletonclass'
from /home/rio/.gem/ruby/1.9.2/gems/bullet-2.1.0/lib/bullet/active_record2.rb:7:in 'block in enable'
from /home/rio/.gem/ruby/1.9.2/gems/bullet-2.1.0/lib/bullet/active_record2.rb:6:in 'class_eval'
from /home/rio/.gem/ruby/1.9.2/gems/bullet-2.1.0/lib/bullet/active_record2.rb:6:in 'enable'
from /home/rio/.gem/ruby/1.9.2/gems/bullet-2.1.0/lib/bullet.rb:41:in 'enable='
from /myrailsapp/config/environments/development.rb:38:in 'block (2 levels) in <top (required)>'
from /home/rio/.gem/ruby/1.9.2/gems/activesupport-3.2.1/lib/active_support/lazy_load_hooks.rb:34:in 'call'
from /home/rio/.gem/ruby/1.9.2/gems/activesupport-3.2.1/lib/active_support/lazy_load_hooks.rb:34:in 'execute_hook'
from /home/rio/.gem/ruby/1.9.2/gems/activesupport-3.2.1/lib/active_support/lazy_load_hooks.rb:43:in 'block in run_load_hooks'
from /home/rio/.gem/ruby/1.9.2/gems/activesupport-3.2.1/lib/active_support/lazy_load_hooks.rb:42:in 'each'
from /home/rio/.gem/ruby/1.9.2/gems/activesupport-3.2.1/lib/active_support/lazy_load_hooks.rb:42:in 'run_load_hooks'
from /home/rio/.gem/ruby/1.9.2/gems/railties-3.2.1/lib/rails/application/finisher.rb:59:in 'block in <module:Finisher>'
from /home/rio/.gem/ruby/1.9.2/gems/railties-3.2.1/lib/rails/initializable.rb:30:in 'instance_exec'
from /home/rio/.gem/ruby/1.9.2/gems/railties-3.2.1/lib/rails/initializable.rb:30:in 'run'
from /home/rio/.gem/ruby/1.9.2/gems/railties-3.2.1/lib/rails/initializable.rb:55:in 'block in run_initializers'
from /home/rio/.gem/ruby/1.9.2/gems/railties-3.2.1/lib/rails/initializable.rb:54:in 'each'
from /home/rio/.gem/ruby/1.9.2/gems/railties-3.2.1/lib/rails/initializable.rb:54:in 'run_initializers'
from /home/rio/.gem/ruby/1.9.2/gems/railties-3.2.1/lib/rails/application.rb:136:in 'initialize!'
from /home/rio/.gem/ruby/1.9.2/gems/railties-3.2.1/lib/rails/railtie/configurable.rb:30:in 'method_missing'
from /myrailsapp/config/environment.rb:5:in '<top (required)>'
from /home/rio/.gem/ruby/1.9.2/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:251:in 'require'
from /home/rio/.gem/ruby/1.9.2/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:251:in 'block in require'
from /home/rio/.gem/ruby/1.9.2/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:236:in 'load_dependency'
from /home/rio/.gem/ruby/1.9.2/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:251:in 'require'
from /myrailsapp/config.ru:4:in 'block in <main>'
from /home/rio/.gem/ruby/1.9.2/gems/rack-1.4.1/lib/rack/builder.rb:51:in 'instance_eval'
from /home/rio/.gem/ruby/1.9.2/gems/rack-1.4.1/lib/rack/builder.rb:51:in 'initialize'
from /myrailsapp/config.ru:1:in 'new'
from /myrailsapp/config.ru:1:in '<main>'
from /home/rio/.gem/ruby/1.9.2/gems/rack-1.4.1/lib/rack/builder.rb:40:in 'eval'
from /home/rio/.gem/ruby/1.9.2/gems/rack-1.4.1/lib/rack/builder.rb:40:in 'parse_file'
from /home/rio/.gem/ruby/1.9.2/gems/rack-1.4.1/lib/rack/server.rb:200:in 'app'
from /home/rio/.gem/ruby/1.9.2/gems/railties-3.2.1/lib/rails/commands/server.rb:46:in 'app'
from /home/rio/.gem/ruby/1.9.2/gems/rack-1.4.1/lib/rack/server.rb:301:in 'wrapped_app'
from /home/rio/.gem/ruby/1.9.2/gems/rack-1.4.1/lib/rack/server.rb:252:in 'start'
from /home/rio/.gem/ruby/1.9.2/gems/railties-3.2.1/lib/rails/commands/server.rb:70:in 'start'
from /home/rio/.gem/ruby/1.9.2/gems/railties-3.2.1/lib/rails/commands.rb:55:in 'block in <top (required)>'
from /home/rio/.gem/ruby/1.9.2/gems/railties-3.2.1/lib/rails/commands.rb:50:in 'tap'
from /home/rio/.gem/ruby/1.9.2/gems/railties-3.2.1/lib/rails/commands.rb:50:in '<top (required)>'
from script/rails:6:in 'require'
Something it stopped my server.
I suppose I can use it when I running test, it is horrible. Before I use bullet all test take 15 mins, after enable bullet it takes 10 hours.
I'm sorry but I am currently unable to reproduce this in a test case: basically changing an enumerable while iterating is undefined behaviour in ruby <1.9 but is explicitly forbidden in 1.9, which revelaed the problem in Bullet::Detector::Association#add_eager_loadings: the eager_loadings structure is looped while at the same time objects are removed and added to it which at least in one situation reliably caused CPU spikes for me on 1.8.7, (and the error on 1.9) but the result may vary depending on os, compiler, cpu etc. so it's very hard to reproduce.
I am not sure why this code is structured thus, so I am unable to provide an insight in this, but I have a fix in 7b6cd07 which seems to still let tests pass. Probably some tests for this are waiting to be written :)
RuntimeError: Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
Error is present on Rails 3.2.1
Using jruby 1.6.7
JDBC adpater https://github.com/jruby/activerecord-jdbc-adapter.git
Composite primary key
I'm using Rails 3.0.0.beta3 and have a nested eager load that drives my CPU to 100% and takes 30-60 seconds to complete. App looks something like this:
Models:
Post (has_many :comments)
Comment (belongs_to :post, has_many :ratings)
Rating (belongs_to :comment)
Sample queries:
Takes < 0.01 sec : r = Rating.limit(20).includes(:comment)
Takes < 0.01 sec : c = Comment.limit(20).includes(:post)
Takes > 30 sec : r = Rating.limit(20).includes(:comment => :post)
The last query, with the nested eager load, drives my CPU to 100% for a very long time. The database queries (seen in development.log) all only take a few milliseconds. The long delay is between the second and third queries (i.e. between the "select comments" and "select posts").
After disabling Bullet, the nested eager load takes just a few milliseconds.
I've built a barebones Rails 3.0.0beta3 app with a sample DB that demonstrates this, in case you need it.
Thanks for the great gem!
Has anyone else had this issue?
I have 2 models:
Place and an Address where address is polymorphic. Where I try to run a query like:
Place.includes(:address).joins(:address).where(:addresses =>{:city => "someCity"})
I get the following error thrown:
RuntimeError: can't add a new key into hash during iteration
from /home/joelmats/.rvm/gems/ruby-1.9.2-p136/gems/bullet-2.0.1/lib/bullet/registry/association.rb:5:in
merge!' from /home/joelmats/.rvm/gems/ruby-1.9.2-p136/gems/bullet-2.0.1/lib/bullet/registry/association.rb:5:in
merge'
from /home/joelmats/.rvm/gems/ruby-1.9.2-p136/gems/bullet-2.0.1/lib/bullet/detector/association.rb:52:in block in add_eager_loadings' from /home/joelmats/.rvm/gems/ruby-1.9.2-p136/gems/bullet-2.0.1/lib/bullet/registry/base.rb:15:in
each'
from /home/joelmats/.rvm/gems/ruby-1.9.2-p136/gems/bullet-2.0.1/lib/bullet/registry/base.rb:15:in each' from /home/joelmats/.rvm/gems/ruby-1.9.2-p136/gems/bullet-2.0.1/lib/bullet/detector/association.rb:42:in
add_eager_loadings'
from /home/joelmats/.rvm/gems/ruby-1.9.2-p136/gems/bullet-2.0.1/lib/bullet/active_record3.rb:32:in preload_associations' from /home/joelmats/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.6/lib/active_record/relation.rb:68:in
block in to_a'
from /home/joelmats/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.6/lib/active_record/relation.rb:68:in each' from /home/joelmats/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.6/lib/active_record/relation.rb:68:in
to_a'
from /home/joelmats/.rvm/gems/ruby-1.9.2-p136/gems/bullet-2.0.1/lib/bullet/active_record3.rb:10:in to_a' from /home/joelmats/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.6/lib/active_record/relation.rb:359:in
inspect'
from /home/joelmats/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.6/lib/rails/commands/console.rb:44:in start' from /home/joelmats/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.6/lib/rails/commands/console.rb:8:in
start'
from /home/joelmats/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.6/lib/rails/commands.rb:23:in `<top (required)>'
Hi there,
i get a The error occurred while evaluating nil.collect
bullet (2.0.1) lib/bullet/detector/unused_eager_association.rb:26:in `call_object_association'
error on ree-1.8.7
i solved the problem with changing flatten! in flatten in line 12 in association.rb
flatten! gives back nil when there are no changes.
Thanks for a great tool!
Another common issue with sometimes disastrous consequences similar to those of N+1 queries is improper .include? calls.
I.E.
class MyObject
has_many :mappings
has_many :other_objects, :through => :mappings
end
my_object.other_objects.include?(my_other_object)
would be better implemented as
my_object.other_objects.where(:id => my_other_object.id).exists?
@mtodd PDI
Looks like an edge case, for your information.
Models:
class Document < AR
acts_as_tree
belongs_to :author
end
class Page < Document
end
class Folder < Document
end
In the controller:
@document = Document.find_by_permalink(params[:id], :include => [:author])
Error:
Unused Eager Loading detected
Folder => [:author]
Remove from your finder: :include => [:author]
N+1 Query detected
Page => [:author]
Add to your finder: :include => [:author]
I hope this helps someone!
Sometime user use :include to get associations eager loading but not use. Find them and give user a suggestion to remove the unused associations eager loaded.
Setting the growl_password no longer seems to be possible - I unpacked the gem and had a brief look around, found nothing. Is this no longer supported?
I've installed bullet 1.7.6 into a rails 2.3.8 app using bundler, and have added the following configuration to config/development.rb and confirmed growl is working ("Bullet Growl notifications have been turned on" appears on first request). However there is no other indication that bullet is working - nothing in log/bullet.log and no growl or javascript messages. I'm pretty sure I'm hitting pages which should detect problems. This is on Mac OS 10.6.4 using passenger (also tried script/server).
config.after_initialize do
Bullet.enable = true
Bullet.alert = true
Bullet.bullet_logger = true
Bullet.console = true
Bullet.growl = true
Bullet.rails_logger = true
Bullet.disable_browser_cache = true
end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.