Class: DownloadablesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/downloadables_controller.rb', line 20

def create
  @downloadable = Downloadable.new(params[:downloadable])
  if @downloadable.save
    flash[:notice] = "Successfully created downloadable."
    redirect_to :back
  else
    render :action => 'new'
  end
end

#destroyObject



45
46
47
48
49
50
# File 'app/controllers/downloadables_controller.rb', line 45

def destroy
  @downloadable = Downloadable.find(params[:id])
  @downloadable.destroy
  flash[:notice] = "Successfully destroyed downloadable."
  redirect_to :back
end

#editObject



30
31
32
33
# File 'app/controllers/downloadables_controller.rb', line 30

def edit
  @downloadable = Downloadable.find(params[:id])
  render :layout => false
end

#indexObject



5
6
7
# File 'app/controllers/downloadables_controller.rb', line 5

def index
  @downloadables = Downloadable.all
end

#newObject



14
15
16
17
18
# File 'app/controllers/downloadables_controller.rb', line 14

def new
  @index = Index.find(params[:index_id])
  @downloadable = @index.downloadables.build(:priority => ((@index.assets.first.lowest_priority + 1) rescue 0))
  render :layout => false
end

#showObject



9
10
11
12
# File 'app/controllers/downloadables_controller.rb', line 9

def show
  @downloadable = Downloadable.find(params[:id])
  send_data(@downloadable.asset.url, :filename => @downloadable.asset_file_name, :type => @downloadable.asset_content_type, :disposition => 'attachment')
end

#updateObject



35
36
37
38
39
40
41
42
43
# File 'app/controllers/downloadables_controller.rb', line 35

def update
  @downloadable = Downloadable.find(params[:id])
  if @downloadable.update_attributes(params[:downloadable])
    flash[:notice] = "Successfully updated downloadable."
    redirect_to :back
  else
    render :action => 'edit'
  end
end