Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Debugging Rails 3.2 auto-explain issue

  • Loading branch information...
commit 584441eaa3da15d0d5556d1d0abf1175837e933d 1 parent d9091d7
Jeff Casimir jcasimir authored
3  Gemfile
... ... @@ -1,6 +1,7 @@
1 1 source 'http://rubygems.org'
2 2
3   -gem 'rails', '3.2.1'
  3 +#gem 'rails', '3.2.1'
  4 +gem 'rails', :git => 'https://github.com/rails/rails.git', :branch => "3-2-stable"
4 5 gem 'sqlite3'
5 6 gem 'jquery-rails'
6 7
42 Gemfile.lock
... ... @@ -1,5 +1,7 @@
1   -GEM
2   - remote: http://rubygems.org/
  1 +GIT
  2 + remote: https://github.com/rails/rails.git
  3 + revision: 4ca633e4663b62653ee017e5fd02dd86f06d1200
  4 + branch: 3-2-stable
3 5 specs:
4 6 actionmailer (3.2.1)
5 7 actionpack (= 3.2.1)
@@ -28,6 +30,25 @@ GEM
28 30 activesupport (3.2.1)
29 31 i18n (~> 0.6)
30 32 multi_json (~> 1.0)
  33 + rails (3.2.1)
  34 + actionmailer (= 3.2.1)
  35 + actionpack (= 3.2.1)
  36 + activerecord (= 3.2.1)
  37 + activeresource (= 3.2.1)
  38 + activesupport (= 3.2.1)
  39 + bundler (~> 1.0)
  40 + railties (= 3.2.1)
  41 + railties (3.2.1)
  42 + actionpack (= 3.2.1)
  43 + activesupport (= 3.2.1)
  44 + rack-ssl (~> 1.3.2)
  45 + rake (>= 0.8.7)
  46 + rdoc (~> 3.4)
  47 + thor (~> 0.14.6)
  48 +
  49 +GEM
  50 + remote: http://rubygems.org/
  51 + specs:
31 52 addressable (2.2.6)
32 53 arel (3.0.0)
33 54 builder (3.0.0)
@@ -85,21 +106,6 @@ GEM
85 106 rack
86 107 rack-test (0.6.1)
87 108 rack (>= 1.0)
88   - rails (3.2.1)
89   - actionmailer (= 3.2.1)
90   - actionpack (= 3.2.1)
91   - activerecord (= 3.2.1)
92   - activeresource (= 3.2.1)
93   - activesupport (= 3.2.1)
94   - bundler (~> 1.0)
95   - railties (= 3.2.1)
96   - railties (3.2.1)
97   - actionpack (= 3.2.1)
98   - activesupport (= 3.2.1)
99   - rack-ssl (~> 1.3.2)
100   - rake (>= 0.8.7)
101   - rdoc (~> 3.4)
102   - thor (~> 0.14.6)
103 109 rake (0.9.2.2)
104 110 rdoc (3.12)
105 111 json (~> 1.4)
@@ -157,7 +163,7 @@ DEPENDENCIES
157 163 guard-rspec
158 164 jquery-rails
159 165 launchy
160   - rails (= 3.2.1)
  166 + rails!
161 167 rspec-rails
162 168 sass-rails
163 169 sqlite3
6 app/models/article.rb
@@ -6,6 +6,8 @@ class Article < ActiveRecord::Base
6 6 has_many :taggings
7 7 has_many :tags, :through => :taggings
8 8
  9 + default_scope :include => [:comments, :tags]
  10 +
9 11 def to_s
10 12 return title
11 13 end
@@ -15,7 +17,7 @@ def tag_list
15 17 end
16 18
17 19 def self.most_popular
18   - Article.all.sort_by{|a| a.comments.size}.last
  20 + all.sort_by{|a| a.comments.count }.last
19 21 end
20 22
21 23 def tag_list=(input)
@@ -60,7 +62,7 @@ def self.generate_samples(quantity = 1000)
60 62 article.created_at = article.created_at - (rand(300) + 100).hours
61 63 article.tags = tags.sort_by{ rand }[0..rand(tags.length)]
62 64 article.save
63   - (rand(10)).times do
  65 + (rand(10) + 1).times do
64 66 Fabricate(:comment, :article => article, :created_at => article.created_at + rand(100).hours)
65 67 end
66 68 yield if block_given?
1  lib/tasks/sample_data.rake
... ... @@ -1,4 +1,5 @@
1 1 namespace :samples do
  2 + desc "Generate a thousand sample articles"
2 3 task :generate_many => :environment do
3 4 puts "Generating 1000 sample articles..."
4 5 Article.generate_samples(1000){ printf "." }

0 comments on commit 584441e

Please sign in to comment.
Something went wrong with that request. Please try again.