Class: DownloadablesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- DownloadablesController
- Defined in:
- app/controllers/downloadables_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
30 31 32 33 |
# File 'app/controllers/downloadables_controller.rb', line 30 def edit @downloadable = Downloadable.find(params[:id]) render :layout => false end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/downloadables_controller.rb', line 5 def index @downloadables = Downloadable.all end |
#new ⇒ Object
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 |
#show ⇒ Object
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 |
#update ⇒ Object
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 |