Sha256: 3dae5b5ebbb57cc143f50a938f897958dfbdcd03db4c369d9235a3f006940bc4

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

require_dependency "storytime/application_controller"

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

      def index
        redirect_to url_for([:dashboard, Storytime::Post]) unless Storytime.enable_file_upload

        @media = Media.order("created_at DESC").page(params[:page]).per(9)
        authorize @media

        @large_gallery = false if params[:large_gallery] == "false"

        render partial: "gallery", content_type: Mime::HTML if request.xhr?
      end

      def create
        @media = current_user.storytime_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

4 entries across 4 versions & 1 rubygems

Version Path
storytime-1.0.5 app/controllers/storytime/dashboard/media_controller.rb
storytime-1.0.2 app/controllers/storytime/dashboard/media_controller.rb
storytime-1.0.1 app/controllers/storytime/dashboard/media_controller.rb
storytime-1.0.0 app/controllers/storytime/dashboard/media_controller.rb