Class: Odania::TagsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/odania/tags_controller.rb

Instance Method Summary collapse

Instance Method Details

#auto_completeObject



16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/odania/tags_controller.rb', line 16

def auto_complete
	term = params[:term].to_s
	result = []

	Odania::Tag.where(language_id: current_menu.language_id).where('name LIKE ?', "%#{term}%").order('count DESC').limit(10).each do |tag|
		result << {id: tag.name, label: tag.name, value: tag.name}
	end

	render json: result
end

#indexObject



4
5
6
# File 'app/controllers/odania/tags_controller.rb', line 4

def index
	@odania_tags = current_site.tag_counts_on(:tags)
end

#showObject



8
9
10
11
12
13
14
# File 'app/controllers/odania/tags_controller.rb', line 8

def show
	@tag = current_site.tags.where(name: params[:tag]).first
	return render_not_found if @tag.nil?

	@tag_xrefs = @tag.tag_xrefs
	return render_not_found if @tag_xrefs.empty?
end