Sha256: e1599a52929c400e53a17cf87acd1831bb3c4aa815916eb1dacab44c975c89d4

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

module Kublog
  class ImagesController < ApplicationController
    include XhrUpload::FileHelper
    
    before_filter  :set_image_file, :only => :create
    
    def create
      @image = Image.new(params[:image])
      respond_to do |format|
        if @image.save
          format.json { render :json => @image }
        else
          format.json { render :json => @image.errors.messages, :status => :unprocessable_entity }
        end
      end
    end
    
    def update
      @image = Image.find(params[:id])
      respond_to do |format|
        if @image.update_attributes(params[:image])
          format.json { render :json => @image }
        else
          format.json { render :json => @image.errors.messages, :status => :unprocessable_entity }
        end
      end
    end
    
    def destroy
      @image = Image.find(params[:id])
      @image.destroy
      respond_to do |format|
        format.json{ render :json => @image }
      end
    end
    
    private
    
    def set_image_file
      params[:image] ||= {:file => received_file}
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kublog-0.9.0 app/controllers/kublog/images_controller.rb
kublog-0.0.1.1 app/controllers/kublog/images_controller.rb