Class: Admin::MediaController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/admin/media_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/admin/media_controller.rb', line 19

def create
	@page_name = "New Media"
	add_breadcrumb "New", :new_admin_medium_path
	@media = SpudMedia.new(params[:spud_media])
	location = admin_media_path
	if @media.save
		flash[:notice] = "File uploaded successfully" 
		if @media.is_image?
			location = edit_admin_medium_path(@media.id)
		end
	end
	respond_with @media, :location => location
end

#destroyObject



47
48
49
50
# File 'app/controllers/admin/media_controller.rb', line 47

def destroy
	flash[:notice] = "File successfully destroyed" if @media.destroy
	respond_with @media, :location => admin_media_path
end

#editObject



33
34
35
36
37
38
# File 'app/controllers/admin/media_controller.rb', line 33

def edit
	if !@media.is_image?
		flash[:error] = "Unable to edit #{@media.attachment_file_name}"
		redirect_to admin_media_path
	end
end

#indexObject



7
8
9
10
# File 'app/controllers/admin/media_controller.rb', line 7

def index
	@media = SpudMedia.order("created_at DESC").paginate :page => params[:page]
	respond_with @media
end

#newObject



12
13
14
15
16
17
# File 'app/controllers/admin/media_controller.rb', line 12

def new
	@page_name = "New Media"
	add_breadcrumb "New", :new_admin_medium_path
	@media = SpudMedia.new
	respond_with @media
end

#set_accessObject



52
53
54
55
56
# File 'app/controllers/admin/media_controller.rb', line 52

def set_access
	is_protected = params[:protected] || false
	@media.update_attribute(:is_protected, is_protected)
	respond_with @media, :location => admin_media_path
end

#updateObject



40
41
42
43
44
45
# File 'app/controllers/admin/media_controller.rb', line 40

def update
	if @media.update_attributes(params[:spud_media])
		@media.attachment.reprocess!
	end
	respond_with @media, :location => admin_media_path
end