Class: Wafflemix::AssetsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/wafflemix/assets_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#menu_items

Instance Method Details

#createObject



38
39
40
41
42
43
44
45
# File 'app/controllers/wafflemix/assets_controller.rb', line 38

def create
  @asset = Asset.new(params[:asset])
  if @asset.save
    render :json => {image: {url: "#{@asset.asset.url}"}}
  else
    render :json => [{:error => "custom_failure"}], :status => 304
  end
end

#destroyObject



61
62
63
64
65
66
67
68
69
# File 'app/controllers/wafflemix/assets_controller.rb', line 61

def destroy
  @asset = Asset.find(params[:id])
  @asset.destroy

  respond_to do |format|
    format.html { redirect_to admin_assets_path }
    format.json { head :no_content }
  end
end

#editObject



34
35
36
# File 'app/controllers/wafflemix/assets_controller.rb', line 34

def edit
  @asset = Asset.find(params[:id])
end

#indexObject



7
8
9
10
11
12
13
14
# File 'app/controllers/wafflemix/assets_controller.rb', line 7

def index
  @assets = Asset.all

  respond_to do |format|
    format.html
    format.json { render :json => @assets.collect { |p| p.to_jq_upload }.to_json }
  end
end

#newObject



25
26
27
28
29
30
31
32
# File 'app/controllers/wafflemix/assets_controller.rb', line 25

def new
  @asset = Asset.new

  respond_to do |format|
    format.html
    format.json { render json: @asset }
  end
end

#showObject



16
17
18
19
20
21
22
23
# File 'app/controllers/wafflemix/assets_controller.rb', line 16

def show
  @asset = Asset.find(params[:id])

  respond_to do |format|
    format.html
    format.json { render json: @asset }
  end
end

#updateObject



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/controllers/wafflemix/assets_controller.rb', line 47

def update
  @asset = Asset.find(params[:id])

  respond_to do |format|
    if @asset.update_attributes(params[:asset])
      format.html { redirect_to [:admin, @asset], notice: 'Asset was successfully updated.' }
      format.json { head :no_content }
    else
      format.html { render action: "edit" }
      format.json { render json: @asset.errors, status: :unprocessable_entity }
    end
  end
end