Commit e2a437f724e89de22fa4257ef588ed24f4021cee

Authored by Antonio Terceiro
1 parent 75a35fb9

ActionItem1026: ask the environment for its tags

app/controllers/public/search_controller.rb
@@ -209,14 +209,14 @@ class SearchController < PublicController @@ -209,14 +209,14 @@ class SearchController < PublicController
209 attr_reader :category 209 attr_reader :category
210 210
211 def tags 211 def tags
212 - @tags = Tag.find(:all).inject({}) do |memo,tag| 212 + @tags = environment.tags.inject({}) do |memo,tag|
213 memo[tag.name] = tag.taggings.count 213 memo[tag.name] = tag.taggings.count
214 memo 214 memo
215 end 215 end
216 end 216 end
217 217
218 def tag 218 def tag
219 - @tag = Tag.find_by_name(params[:tag]) 219 + @tag = environment.tags.find_by_name(params[:tag])
220 @tagged = @tag.taggings.map(&:taggable) 220 @tagged = @tag.taggings.map(&:taggable)
221 end 221 end
222 222
app/models/environment.rb
@@ -444,6 +444,8 @@ class Environment < ActiveRecord::Base @@ -444,6 +444,8 @@ class Environment < ActiveRecord::Base
444 444
445 has_many :events, :through => :profiles, :source => :articles, :class_name => 'Event' 445 has_many :events, :through => :profiles, :source => :articles, :class_name => 'Event'
446 446
  447 + has_many :tags, :through => :articles
  448 +
447 def theme 449 def theme
448 self[:theme] || 'default' 450 self[:theme] || 'default'
449 end 451 end