Permalink
Browse files

Debugging Rails 3.2 auto-explain issue

  • Loading branch information...
1 parent d9091d7 commit 584441eaa3da15d0d5556d1d0abf1175837e933d @jcasimir jcasimir committed Feb 3, 2012
Showing with 31 additions and 21 deletions.
  1. +2 −1 Gemfile
  2. +24 −18 Gemfile.lock
  3. +4 −2 app/models/article.rb
  4. +1 −0 lib/tasks/sample_data.rake
View
3 Gemfile
@@ -1,6 +1,7 @@
source 'http://rubygems.org'
-gem 'rails', '3.2.1'
+#gem 'rails', '3.2.1'
+gem 'rails', :git => 'https://github.com/rails/rails.git', :branch => "3-2-stable"
gem 'sqlite3'
gem 'jquery-rails'
View
42 Gemfile.lock
@@ -1,5 +1,7 @@
-GEM
- remote: http://rubygems.org/
+GIT
+ remote: https://github.com/rails/rails.git
+ revision: 4ca633e4663b62653ee017e5fd02dd86f06d1200
+ branch: 3-2-stable
specs:
actionmailer (3.2.1)
actionpack (= 3.2.1)
@@ -28,6 +30,25 @@ GEM
activesupport (3.2.1)
i18n (~> 0.6)
multi_json (~> 1.0)
+ rails (3.2.1)
+ actionmailer (= 3.2.1)
+ actionpack (= 3.2.1)
+ activerecord (= 3.2.1)
+ activeresource (= 3.2.1)
+ activesupport (= 3.2.1)
+ bundler (~> 1.0)
+ railties (= 3.2.1)
+ railties (3.2.1)
+ actionpack (= 3.2.1)
+ activesupport (= 3.2.1)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
addressable (2.2.6)
arel (3.0.0)
builder (3.0.0)
@@ -85,21 +106,6 @@ GEM
rack
rack-test (0.6.1)
rack (>= 1.0)
- rails (3.2.1)
- actionmailer (= 3.2.1)
- actionpack (= 3.2.1)
- activerecord (= 3.2.1)
- activeresource (= 3.2.1)
- activesupport (= 3.2.1)
- bundler (~> 1.0)
- railties (= 3.2.1)
- railties (3.2.1)
- actionpack (= 3.2.1)
- activesupport (= 3.2.1)
- rack-ssl (~> 1.3.2)
- rake (>= 0.8.7)
- rdoc (~> 3.4)
- thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
@@ -157,7 +163,7 @@ DEPENDENCIES
guard-rspec
jquery-rails
launchy
- rails (= 3.2.1)
+ rails!
rspec-rails
sass-rails
sqlite3
View
6 app/models/article.rb
@@ -6,6 +6,8 @@ class Article < ActiveRecord::Base
has_many :taggings
has_many :tags, :through => :taggings
+ default_scope :include => [:comments, :tags]
+
def to_s
return title
end
@@ -15,7 +17,7 @@ def tag_list
end
def self.most_popular
- Article.all.sort_by{|a| a.comments.size}.last
+ all.sort_by{|a| a.comments.count }.last
end
def tag_list=(input)
@@ -60,7 +62,7 @@ def self.generate_samples(quantity = 1000)
article.created_at = article.created_at - (rand(300) + 100).hours
article.tags = tags.sort_by{ rand }[0..rand(tags.length)]
article.save
- (rand(10)).times do
+ (rand(10) + 1).times do
Fabricate(:comment, :article => article, :created_at => article.created_at + rand(100).hours)
end
yield if block_given?
View
1 lib/tasks/sample_data.rake
@@ -1,4 +1,5 @@
namespace :samples do
+ desc "Generate a thousand sample articles"
task :generate_many => :environment do
puts "Generating 1000 sample articles..."
Article.generate_samples(1000){ printf "." }

0 comments on commit 584441e

Please sign in to comment.