diff options
| author | hukl <contact@smyck.org> | 2009-04-24 11:43:08 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-04-25 14:55:27 +0200 |
| commit | cf1b60e0cfa7d1a8f4a80d686649cc12e73a634e (patch) | |
| tree | b68bd845d290ce968892c4532bcff52083925834 /app/controllers/assets_controller.rb | |
| parent | b2b78c06074046bd73cc3408a29386a976f0469c (diff) | |
Integrated basic Asset upload functionality. You can upload files now and use their url in pages.
Diffstat (limited to 'app/controllers/assets_controller.rb')
| -rw-r--r-- | app/controllers/assets_controller.rb | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb new file mode 100644 index 0000000..4734a54 --- /dev/null +++ b/app/controllers/assets_controller.rb | |||
| @@ -0,0 +1,88 @@ | |||
| 1 | class AssetsController < ApplicationController | ||
| 2 | |||
| 3 | layout 'admin' | ||
| 4 | |||
| 5 | # GET /assets | ||
| 6 | # GET /assets.xml | ||
| 7 | def index | ||
| 8 | @assets = Asset.all | ||
| 9 | |||
| 10 | respond_to do |format| | ||
| 11 | format.html # index.html.erb | ||
| 12 | format.xml { render :xml => @assets } | ||
| 13 | end | ||
| 14 | end | ||
| 15 | |||
| 16 | # GET /assets/1 | ||
| 17 | # GET /assets/1.xml | ||
| 18 | def show | ||
| 19 | @asset = Asset.find(params[:id]) | ||
| 20 | |||
| 21 | respond_to do |format| | ||
| 22 | format.html # show.html.erb | ||
| 23 | format.xml { render :xml => @asset } | ||
| 24 | end | ||
| 25 | end | ||
| 26 | |||
| 27 | # GET /assets/new | ||
| 28 | # GET /assets/new.xml | ||
| 29 | def new | ||
| 30 | @asset = Asset.new | ||
| 31 | |||
| 32 | respond_to do |format| | ||
| 33 | format.html # new.html.erb | ||
| 34 | format.xml { render :xml => @asset } | ||
| 35 | end | ||
| 36 | end | ||
| 37 | |||
| 38 | # GET /assets/1/edit | ||
| 39 | def edit | ||
| 40 | @asset = Asset.find(params[:id]) | ||
| 41 | end | ||
| 42 | |||
| 43 | # POST /assets | ||
| 44 | # POST /assets.xml | ||
| 45 | def create | ||
| 46 | @asset = Asset.new(params[:asset]) | ||
| 47 | |||
| 48 | respond_to do |format| | ||
| 49 | if @asset.save | ||
| 50 | flash[:notice] = 'Asset was successfully created.' | ||
| 51 | format.html { redirect_to(@asset) } | ||
| 52 | format.xml { render :xml => @asset, :status => :created, :location => @asset } | ||
| 53 | else | ||
| 54 | format.html { render :action => "new" } | ||
| 55 | format.xml { render :xml => @asset.errors, :status => :unprocessable_entity } | ||
| 56 | end | ||
| 57 | end | ||
| 58 | end | ||
| 59 | |||
| 60 | # PUT /assets/1 | ||
| 61 | # PUT /assets/1.xml | ||
| 62 | def update | ||
| 63 | @asset = Asset.find(params[:id]) | ||
| 64 | |||
| 65 | respond_to do |format| | ||
| 66 | if @asset.update_attributes(params[:asset]) | ||
| 67 | flash[:notice] = 'Asset was successfully updated.' | ||
| 68 | format.html { redirect_to(@asset) } | ||
| 69 | format.xml { head :ok } | ||
| 70 | else | ||
| 71 | format.html { render :action => "edit" } | ||
| 72 | format.xml { render :xml => @asset.errors, :status => :unprocessable_entity } | ||
| 73 | end | ||
| 74 | end | ||
| 75 | end | ||
| 76 | |||
| 77 | # DELETE /assets/1 | ||
| 78 | # DELETE /assets/1.xml | ||
| 79 | def destroy | ||
| 80 | @asset = Asset.find(params[:id]) | ||
| 81 | @asset.destroy | ||
| 82 | |||
| 83 | respond_to do |format| | ||
| 84 | format.html { redirect_to(assets_url) } | ||
| 85 | format.xml { head :ok } | ||
| 86 | end | ||
| 87 | end | ||
| 88 | end | ||
