Skip to content

Commit

Permalink
Added the bullet gem and some eager loading
Browse files Browse the repository at this point in the history
  • Loading branch information
wahl77 committed Sep 25, 2013
1 parent f2d5998 commit 1fa992a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ gem 'jbuilder', '~> 1.2'
gem 'sorcery'
gem 'haml-rails'
gem 'carrierwave'
gem 'rmagick', '2.13.2', :git=>'http://github.com/rmagick/rmagick.git'
gem 'rmagick'
gem 'gmaps4rails'
gem 'geocoder'
gem 'cancan'
Expand All @@ -44,6 +44,7 @@ group :development do
gem 'binding_of_caller'
gem 'meta_request'
gem 'rack-mini-profiler'
gem 'bullet'
end

group :test, :development do
Expand Down
13 changes: 6 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
GIT
remote: http://github.com/rmagick/rmagick.git
revision: 962d56cba3a132d590be1dd062f2a3a2efa48545
specs:
rmagick (2.13.2)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -40,6 +34,8 @@ GEM
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.1.4)
bullet (4.6.0)
uniform_notifier
callsite (0.0.11)
cancan (1.6.10)
capybara (2.1.0)
Expand Down Expand Up @@ -213,6 +209,7 @@ GEM
ffi (>= 0.5.0)
rdoc (3.12.2)
json (~> 1.4)
rmagick (2.13.2)
rsolr (1.0.9)
builder (>= 2.1.2)
rspec (2.14.1)
Expand Down Expand Up @@ -277,6 +274,7 @@ GEM
uglifier (2.2.1)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
uniform_notifier (1.3.0)
websocket (1.0.7)
xpath (2.0.0)
nokogiri (~> 1.3)
Expand All @@ -289,6 +287,7 @@ PLATFORMS
DEPENDENCIES
better_errors
binding_of_caller
bullet
cancan
capybara
carrierwave
Expand All @@ -313,7 +312,7 @@ DEPENDENCIES
pry-rails
rack-mini-profiler
rails (= 4.0.0)
rmagick (= 2.13.2)!
rmagick
rspec-rails
sass-rails (~> 4.0.0)
sdoc
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def search
@range = params[:range] ? params[:range].to_f : RANGE_CONSTANT
@range = @range * current_user.profile.distance_multiplier if current_user

@items = (params[:query] && !params[:query].blank?) ? Item.item_search(@query, @address, @range, @categories).results : Item.near(@address, @range, @categories)
@items = (params[:query] && !params[:query].blank?) ? Item.item_search(@query, @address, @range, @categories).results : Item.near(@address, @range, @categories).includes(:user, :address, :images)

@items = @items.sample(4) unless current_user
respond_to do |format|
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/static_pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class StaticPagesController < ApplicationController

def index
@address = user_current_location
@items = Item.near(@address, RANGE_CONSTANT).sample(4).shuffle
@items = Item.near(@address, RANGE_CONSTANT).includes(:address, :user).sample(4).shuffle
end

def about
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/show.haml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
.row
.col-lg-6
- current_user.addresses.each do |address|
- current_user.addresses.includes(:country).each do |address|
.row
.col-lg-6
%address
Expand Down
5 changes: 5 additions & 0 deletions config/initializers/bullet.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if defined? Bullet
Bullet.enable = true
#Bullet.alert = true
Bullet.bullet_logger = true
end

0 comments on commit 1fa992a

Please sign in to comment.