class MediaController < AbstractResourcesController def update_crop authorize resource result = resource.new_record? ? resource.save(resource_params) : resource.update_attributes(resource_params) render layout: false end def crop authorize resource render layout: false end # # def index # authorize Medium # render :json => resources.collect { |p| p.to_jq_upload }.to_json # end # # def create # authorize Medium # p_attr = resource_params #params[:media] # p_attr[:media] = p_attr[:media].first if p_attr[:media].class == Array # # @resource = Medium.new(p_attr) # if @resource.save # respond_to do |format| # format.html { # render :json => [@resource.to_jq_upload].to_json, # :content_type => 'text/html', # :layout => false # } # format.json { # render :json => { :files => [@resource.to_jq_upload] } # } # end # else # render :json => [{:error => "custom_failure"}], :status => 304 # end # end # # def destroy # authorize Medium # @resource = Medium.find(params[:id]) # @resource.destroy # render :json => true # end # # # before_action :set_medium, only: [:show, :edit, :update, :destroy] # # # GET /media # def index # @media = Medium.all # end # # # GET /media/1 # def show # end # # # GET /media/new # def new # @medium = Medium.new # end # # # GET /media/1/edit # def edit # end # # # POST /media # def create # @medium = Medium.new(medium_params) # # if @medium.save # redirect_to @medium, notice: 'Medium was successfully created.' # else # render :new # end # end # # # PATCH/PUT /media/1 # def update # if @medium.update(medium_params) # redirect_to @medium, notice: 'Medium was successfully updated.' # else # render :edit # end # end # # # DELETE /media/1 # def destroy # @medium.destroy # redirect_to media_url, notice: 'Medium was successfully destroyed.' # end private # Use callbacks to share common setup or constraints between actions. # def set_medium # @medium = Medium.find(params[:id]) # end # Only allow a trusted parameter "white list" through. def resource_params params.require(:medium).permit(:title, :imageable_id, :imageable_type, :medium, :medium_crop_w, :medium_crop_h, :medium_crop_y, :medium_crop_x, :lng_lat, :description) end end