Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Changed the STI query to use #construct_finder_sql as per Joe Van Dyk…

…'s suggestion.
  • Loading branch information...
commit 75d10b91c8492c51961178714701d3dc9460bc27 1 parent cced76c
Jon Yurek authored January 13, 2009

Showing 1 changed file with 1 addition and 17 deletions. Show diff stats Hide diff stats

  1. 18  tasks/paperclip_tasks.rake
18  tasks/paperclip_tasks.rake
@@ -14,26 +14,10 @@ def obtain_attachments
14 14
   end
15 15
 end
16 16
 
17  
-def quote_table(table)
18  
-  ActiveRecord::Base.connection.quote_table_name(table)
19  
-end
20  
-
21  
-def quote_column(column)
22  
-  ActiveRecord::Base.connection.quote_column_name(column)
23  
-end
24  
-
25  
-def type_condition(klass)
26  
-  if klass.superclass == ActiveRecord::Base
27  
-    ""
28  
-  else
29  
-    "WHERE #{quote_column(klass.inheritance_column)} = '#{klass.name}'"
30  
-  end
31  
-end
32  
-
33 17
 def for_all_attachments
34 18
   klass = obtain_class
35 19
   names = obtain_attachments
36  
-  ids   = klass.connection.select_values("SELECT #{quote_column(klass.primary_key)} FROM #{quote_table(klass.table_name)} #{type_condition(klass)}")
  20
+  ids   = klass.connection.select_values(klass.send(:construct_finder_sql, :select => 'id'))
37 21
 
38 22
   ids.each do |id|
39 23
     instance = klass.find(id)

0 notes on commit 75d10b9

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