Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: app/models/site.rb
- ===================================================================
- --- app/models/site.rb (revision 2383)
- +++ app/models/site.rb (working copy)
- @@ -93,8 +93,11 @@
- end
- def tags
- - Tag.find(:all, :conditions => ['contents.type = ? AND contents.site_id = ?', 'Article', id], :order => 'tags.name',
- - :joins => "INNER JOIN taggings ON taggings.tag_id = tags.id INNER JOIN contents ON (taggings.taggable_id = contents.id AND taggings.taggable_type = 'Content')")
- + Tag.find(:all, :select => "DISTINCT tags.name",
- + :joins => "INNER JOIN taggings ON taggings.tag_id = tags.id INNER JOIN contents ON (taggings.taggable_id = contents.id AND
- + taggings.taggable_type = 'Content')",
- + :conditions => ['contents.type = ? AND contents.site_id = ?', 'Article', id],
- + :order => 'tags.name')
- end
- def theme_path
- Index: test/fixtures/taggings.yml
- ===================================================================
- --- test/fixtures/taggings.yml (revision 2383)
- +++ test/fixtures/taggings.yml (working copy)
- @@ -7,4 +7,19 @@
- id: 2
- tag_id: 2
- taggable_id: 2
- + taggable_type: Content
- +rails_future:
- + id: 3
- + tag_id: 2
- + taggable_id: 5
- + taggable_type: Content
- +mongrel_future:
- + id: 4
- + tag_id: 3
- + taggable_id: 5
- + taggable_type: Content
- +ruby_future:
- + id: 5
- + tag_id: 1
- + taggable_id: 5
- taggable_type: Content
- \ No newline at end of file
- Index: test/unit/tagging_test.rb
- ===================================================================
- --- test/unit/tagging_test.rb (revision 2383)
- +++ test/unit/tagging_test.rb (working copy)
- @@ -74,6 +74,6 @@
- end
- specify "should find by tags in site" do
- - assert_models_equal [tags(:rails)], sites(:first).tags
- + assert_models_equal [tags(:mongrel), tags(:rails), tags(:ruby)], sites(:first).tags
- end
- end
Add Comment
Please, Sign In to add comment