Sha256: bf74e84497657d90605cfbfff0fb8f635c0c6b4941e64e9d52fa6640f357f562

Contents?: true

Size: 885 Bytes

Versions: 1

Compression:

Stored size: 885 Bytes

Contents

require_dependency "storytime/application_controller"

module Storytime
  module Dashboard
    class MediaController < DashboardController
      respond_to :json, only: [:create, :destroy]

      def index
        @media = Media.order("created_at DESC").page(params[:page]).per(10)
        authorize @media
        render partial: "gallery", content_type: Mime::HTML if request.xhr?
      end

      def create
        @media = current_user.media.new(media_params)
        authorize @media
        @media.save
        respond_with :dashboard, @media do |format|
          format.json{ render :show }
        end
      end
      
      def destroy
        @media = Media.find(params[:id])
        authorize @media
        @media.destroy
        respond_with @media
      end

    private

      def media_params
        params.require(:media).permit(:file)
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
storytime-0.0.1 app/controllers/storytime/dashboard/media_controller.rb