Class: Odania::ContentsController

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

Instance Method Summary collapse

Instance Method Details

#indexObject



4
5
6
7
8
9
10
11
12
13
# File 'app/controllers/odania/contents_controller.rb', line 4

def index
	@odania_contents = current_site.contents

	unless params[:tag].nil?
		odania_tag = Odania::Tag.where(name: params[:tag], language_id: current_menu.language_id).first
		@odania_contents = @odania_contents.joins(:tags).where(odania_tag_xrefs: {tag_id: odania_tag.id}) unless odania_tag.nil?
	end

	@odania_contents = @odania_contents.where(language_id: current_menu.language_id).order('created_at DESC')
end

#showObject



15
16
17
18
19
20
21
22
# File 'app/controllers/odania/contents_controller.rb', line 15

def show
	@odania_content = current_site.contents.where(id: params[:id], language_id: current_menu.language_id).first

	return render_not_found if @odania_content.nil?
	return redirect_to odania_content_path(id: @odania_content.to_param) unless @odania_content.to_param.eql? params[:id]

	@widget_id = @odania_content.widget_id
end