Sha256: a7a28a675598578e0bc0e37f8266993fd1a162c9023b2a2792d76797874ee18c

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

class Spud::Admin::MediaController < Spud::Admin::ApplicationController
	layout 'spud/admin/media/detail'
	add_breadcrumb "Media", :spud_admin_media_path
	belongs_to_spud_app :media
	before_filter :load_media,:only => [:edit,:update,:show,:destroy,:set_private,:set_access]
	
	def index
		@media = SpudMedia.order("created_at DESC").paginate :page => params[:page]
		respond_with @media
	end

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

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

	def show
		@page_name = "Media: #{@media.attachment_file_name}"
		add_breadcrumb @media.attachment_file_name, :new_spud_admin_media_path
		respond_with @media
	end

	def update
		
	end

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

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

private
	def load_media
		@media = SpudMedia.where(:id => params[:id]).first
		if @media.blank?
			flash[:error] = "Media Asset not found!"
			redirect_to spud_admin_media_url() and return
		end
		
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spud_media-0.9.0 app/controllers/spud/admin/media_controller.rb