Class: Kublog::ImagesController

Inherits:
ApplicationController show all
Includes:
XhrUpload::FileHelper
Defined in:
app/controllers/kublog/images_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #is_admin?, #require_admin

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/kublog/images_controller.rb', line 7

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

#destroyObject



29
30
31
32
33
34
35
# File 'app/controllers/kublog/images_controller.rb', line 29

def destroy
  @image = Image.find(params[:id])
  @image.destroy
  respond_to do |format|
    format.json{ render :json => @image }
  end
end

#updateObject



18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/kublog/images_controller.rb', line 18

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