Questions tagged [rails-bullet]

Bullet is a ruby gem that helps in improving performance by identifying N+1 queries, advising when to switch eager loading on or off, and when to use counter cache.

The Bullet gem is designed to help developers increase an application's performance by reducing the number of queries it makes. It will watch the queries while developing the application and notify when there is a need for eager loading (N+1 queries), when eager loading is being used unnecessarily, and when to use counter cache.

Best practice is to use Bullet in development mode or custom mode (staging, profile, etc.)

Github project page

12 questions
6
votes
2 answers

Ruby on Rails - Bullet/N+1

On Rails 4. I recently installed the bullet gem for my development environment to clear up my app's N+1 queries. Relevant models: Submissions: Belongs to Categories and Users. Has many SubmissionDetails. Users: Has many Submissions Categories: Has…
Rachel9494
  • 849
  • 1
  • 7
  • 27
4
votes
1 answer

Fix N+1 query in "declarative_authorization" gem using gem "bullet"

Currently I am working on one big web application and to make it work faster I decided to refactor all N+1 queries (to decrease number of requests to database, http://rails-bestpractices.com/posts/29-fix-n-1-queries). So I installed gem "bullet"…
4
votes
1 answer

Reducing n+1 queries using the Bullet and RSpec gems

What is an effective way to use the Bullet Gem with RSpec? Right now I feel if I use it with my current unit test framework I get a lot of notifications or failures of tests because of n+1 queries within the tests themselves that are not related to…
nobody
  • 7,803
  • 11
  • 56
  • 91
3
votes
1 answer

Rails bullet gem slower after adding eager load as advised

I added the bullet gem to advise me of any N+1 queries in dev (Rails 4.0.2) It advised eager loading two parent associations of a model where I'm displaying all its records. Before eager loading one of these belongs-to associations: Completed 200 OK…
rigyt
  • 2,219
  • 3
  • 28
  • 40
3
votes
1 answer

Eager loading in Rails 3?

I am attempting to learn how to increase the performance of Rails applications and the first step I am looking at is eager loading. I've configured the bullet gem which shows where I can make use of eager loading, however, I'm not too sure how to…
dannymcc
  • 3,744
  • 12
  • 52
  • 85
2
votes
1 answer

Rails 4.1.2 can't install bullet gem

I've added to my Gemfile bullet gem: gem "bullet", :group => "development" and in my development.rb I added: config.after_initialize do Bullet.enable = true Bullet.alert = true end When I try to run my rails server I have the following…
Mateusz Urbański
  • 7,352
  • 15
  • 68
  • 133
1
vote
1 answer

How to avoid N+1 queries with Ransack

I've beeen using Ransack in one of my projects and also using Bullet to spot some N+1 queries in my controllers. However, I'm not quite sure how to accomplish that while using Ransack. There are two models involved, Patch and Image. And a Patch…
André Herculano
  • 1,258
  • 20
  • 33
0
votes
1 answer

Error when testing filtering eager loaded data in Rails 7

Currently in my index action I load the data as: posts.includes([:user, :status]) Note: Posts belongs to a user optionally. There are posts that have no user. And then I'm filtering those posts based on different params. Everything worked perfectly…
0
votes
1 answer

acts_as_api and bullet N+1 queries

I am using acts_as_api to provide a JSON response for some models in my system. My API related code is (reduced to make the example easier): # File app/modes/item.rb # API acts_as_api api_accessible :v1_list do |template| template.add :id …
Bustikiller
  • 2,423
  • 2
  • 16
  • 34
0
votes
1 answer

gem bullet enable/disable for some paths/controllers

Can I enable/disable the javascript alerts(but could be even logs) only for some paths/controllers ? I only found how to skip models, but nothing about paths or controllers. I got a lot of alerts on activeadmin and I cannot change that code. For…
Razvan Pavel
  • 321
  • 2
  • 9
0
votes
1 answer

Is it possible to show the gem bullet's aleter only when User.id == 1?

I'm using the gem called "bullet" https://github.com/flyerhzm/bullet This help to avoid N + 1 problem. I'd like to use this in production mode with my account(User.id==1) Is it possible? I've coded this in /config/environments/production.rb but…
MKK
  • 2,713
  • 5
  • 31
  • 51
0
votes
1 answer

.includes method doesn't work

I have installed the gem bullet to enhance performences on my small app (which is running with Rails 4 Edge) However, the '.includes' method doesn't seem to work: def index @articles = Article.includes(:category) end This returns 'can't convert…
sidney
  • 2,704
  • 3
  • 28
  • 44