Class: AttachableAssetsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/attachable_assets_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/attachable_assets_controller.rb', line 36

def create
  @attachable_asset = AttachableAsset.new(params[:attachable_asset])

  respond_to do |format|
    if @attachable_asset.save
      format.html { redirect_to(@attachable_asset)}
      format.json { render :json => @attachable_asset.to_json }
    else
      format.html { render :action => "new" }
      format.json { render :json => { :errors => @attachable_asset.errors }.to_json }
    end
  end
end

#deleteObject



64
65
66
67
68
69
70
71
72
# File 'app/controllers/attachable_assets_controller.rb', line 64

def delete
  @attachable_asset = AttachableAsset.find(params[:id])
  @attachable_asset.destroy
  
  respond_to do |format|
    format.html { redirect_to attachable_assets_path }
    format.json { render :json => { :message => "OK" }.to_json }
  end
end

#editObject



28
29
30
31
32
33
34
# File 'app/controllers/attachable_assets_controller.rb', line 28

def edit
  @attachable_asset = AttachableAsset.find(params[:id])

  respond_to do |format|
    format.html { render :action => "edit" }
  end
end

#indexObject



3
4
5
6
7
8
9
10
# File 'app/controllers/attachable_assets_controller.rb', line 3

def index
  @attachable_assets = AttachableAsset.find(:all)

  respond_to do |format|
    format.html
    format.json { render :json => @attachable_assets.to_json }
  end
end

#newObject



21
22
23
24
25
26
# File 'app/controllers/attachable_assets_controller.rb', line 21

def new
  @attachable_asset = AttachableAsset.new
  respond_to do |format|
    format.html { render :action => "new" }
  end
end

#required_params_present?Boolean

Returns:

  • (Boolean)


74
75
76
77
78
79
80
# File 'app/controllers/attachable_assets_controller.rb', line 74

def required_params_present?
  if !params[:attachable_id]
    raise AttachableException.new("Missing required parameters attachable_id")
  elsif !params[:attachable_type]
    raise AttachableException.new("Missing required parameters attachable_type")
  end
end

#showObject



12
13
14
15
16
17
18
19
# File 'app/controllers/attachable_assets_controller.rb', line 12

def show
  @attachable_asset = AttachableAsset.find(params[:id])

  respond_to do |format|
    format.html { render :action => "show" }
    format.json { render :json => @attachable_asset.to_json }
  end
end

#updateObject



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/controllers/attachable_assets_controller.rb', line 50

def update
  @attachable_asset = AttachableAsset.find(params[:id])

  respond_to do |format|
    if @attachable_asset.update_attributes(params[:attachable_asset])
      format.html { redirect_to(@attachable_asset)}
      format.json { render :json => @attachable_asset.to_json }
    else
      format.html { render :action => "new" }
      format.json { render :json => { :errors => @attachable_asset.errors }.to_json }
    end
  end
end