Sha256: 9afb5e1faf1018fe2ae9d2c6c8675334d87c0095c718534db920d77939abc3b3
Contents?: true
Size: 1.65 KB
Versions: 2
Compression:
Stored size: 1.65 KB
Contents
class Admin::MediaController < Admin::ApplicationController layout 'admin/detail' add_breadcrumb "Media", :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_admin_medium_path @media = SpudMedia.new respond_with @media end 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 def edit if !@media.is_image? flash[:error] = "Unable to edit #{@media.attachment_file_name}" redirect_to admin_media_path end end def update if @media.update_attributes(params[:spud_media]) @media.attachment.reprocess! end respond_with @media, :location => admin_media_path end def destroy flash[:notice] = "File successfully destroyed" if @media.destroy respond_with @media, :location => admin_media_path end def set_access is_protected = params[:protected] || false @media.update_attribute(:is_protected, is_protected) respond_with @media, :location => admin_media_path end private def load_media @media = SpudMedia.where(:id => params[:id]).first if @media.blank? flash[:error] = "Media Asset not found!" redirect_to admin_media_path() and return end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tb_media-1.0.2 | app/controllers/admin/media_controller.rb |
tb_media-1.0.1 | app/controllers/admin/media_controller.rb |