Class: Admin::Odania::ContentsController

Inherits:
AdminController
  • Object
show all
Defined in:
app/controllers/admin/odania/contents_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /admin/contents



29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/admin/odania/contents_controller.rb', line 29

def create
	@admin_content = Odania::Content.new(admin_content_params)
	@admin_content.user_id = current_user.id

	if @admin_content.save
		redirect_to admin_odania_menu_odania_contents_path, notice: 'Content was successfully created.'
	else
		render action: 'new'
	end
end

#destroyObject

DELETE /admin/contents/1



50
51
52
53
# File 'app/controllers/admin/odania/contents_controller.rb', line 50

def destroy
	@admin_content.destroy
	redirect_to admin_odania_menu_odania_contents_url, notice: 'Content was successfully destroyed.'
end

#editObject

GET /admin/contents/1/edit



25
26
# File 'app/controllers/admin/odania/contents_controller.rb', line 25

def edit
end

#indexObject

GET /admin/contents



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

def index
	if @odania_menu.nil?
		@admin_contents = @admin_site.contents.order('title ASC')
	else
		@admin_contents = @admin_site.contents.where(language_id: @odania_menu.language.id).order('title ASC')
	end
end

#newObject

GET /admin/contents/new



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

def new
	@admin_content = Odania::Content.new
	@admin_content.site_id = @admin_site.id
	@admin_content.language_id = @odania_menu.language.id unless @odania_menu.nil?
end

#overviewObject



55
56
57
58
59
60
# File 'app/controllers/admin/odania/contents_controller.rb', line 55

def overview
	menu = Odania::Menu.first
	redirect_to admin_odania_menu_path, notice: 'Create a menu first' if menu.nil?

	redirect_to admin_odania_menu_odania_contents_path(menu_id: menu.id.to_s)
end

#showObject

GET /admin/contents/1



14
15
# File 'app/controllers/admin/odania/contents_controller.rb', line 14

def show
end

#updateObject

PATCH/PUT /admin/contents/1



41
42
43
44
45
46
47
# File 'app/controllers/admin/odania/contents_controller.rb', line 41

def update
	if @admin_content.update(admin_content_params)
		redirect_to admin_odania_menu_odania_contents_path, notice: 'Content was successfully updated.'
	else
		render action: 'edit'
	end
end