public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
Fix Site#tags query to return distinct tags [DeLynn Berry]

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2390 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Mon Oct 23 20:41:13 -0700 2006
commit  1e6504e8f9ebddd39b7e96d2a57f5fbe1b3a0f49
tree    22cc7763d4cd9020d6d9ec84fbcf0412b7aae071
parent  fe2bc95e1741a5684029da3b3971d78c15757474
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 * SVN *
0
 
0
+* Fix Site#tags query to return distinct tags [DeLynn Berry]
0
+
0
 * Simplify and properly test admin/article permissions for non-admins.
0
 
0
 * Change child_section and descendent_section methods in the SiteDrop to search the preloaded sections array.
...
93
94
95
96
97
 
 
 
 
 
98
99
100
...
93
94
95
 
 
96
97
98
99
100
101
102
103
0
@@ -93,8 +93,11 @@ class Site < ActiveRecord::Base
0
   end
0
 
0
   def tags
0
- Tag.find(:all, :conditions => ['contents.type = ? AND contents.site_id = ?', 'Article', id], :order => 'tags.name',
0
- :joins => "INNER JOIN taggings ON taggings.tag_id = tags.id INNER JOIN contents ON (taggings.taggable_id = contents.id AND taggings.taggable_type = 'Content')")
0
+ Tag.find(:all, :select => "DISTINCT tags.name",
0
+ :joins => "INNER JOIN taggings ON taggings.tag_id = tags.id INNER JOIN contents ON (taggings.taggable_id = contents.id AND
0
+ taggings.taggable_type = 'Content')",
0
+ :conditions => ['contents.type = ? AND contents.site_id = ?', 'Article', id],
0
+ :order => 'tags.name')
0
   end
0
 
0
   def theme_path
...
7
8
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
11
...
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
0
@@ -7,4 +7,19 @@ rails_another:
0
   id: 2
0
   tag_id: 2
0
   taggable_id: 2
0
+ taggable_type: Content
0
+rails_future:
0
+ id: 3
0
+ tag_id: 2
0
+ taggable_id: 5
0
+ taggable_type: Content
0
+mongrel_future:
0
+ id: 4
0
+ tag_id: 3
0
+ taggable_id: 5
0
+ taggable_type: Content
0
+ruby_future:
0
+ id: 5
0
+ tag_id: 1
0
+ taggable_id: 5
0
   taggable_type: Content
0
\ No newline at end of file
...
74
75
76
77
 
78
79
...
74
75
76
 
77
78
79
0
@@ -74,6 +74,6 @@ context "Article Tagging" do
0
   end
0
 
0
   specify "should find by tags in site" do
0
- assert_models_equal [tags(:rails)], sites(:first).tags
0
+ assert_models_equal [tags(:mongrel), tags(:rails), tags(:ruby)], sites(:first).tags
0
   end
0
 end

Comments

    No one has commented yet.