From cf1b60e0cfa7d1a8f4a80d686649cc12e73a634e Mon Sep 17 00:00:00 2001 From: hukl Date: Fri, 24 Apr 2009 11:43:08 +0200 Subject: Integrated basic Asset upload functionality. You can upload files now and use their url in pages. --- app/controllers/assets_controller.rb | 88 ++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 app/controllers/assets_controller.rb (limited to 'app/controllers/assets_controller.rb') 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 @@ +class AssetsController < ApplicationController + + layout 'admin' + + # GET /assets + # GET /assets.xml + def index + @assets = Asset.all + + respond_to do |format| + format.html # index.html.erb + format.xml { render :xml => @assets } + end + end + + # GET /assets/1 + # GET /assets/1.xml + def show + @asset = Asset.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.xml { render :xml => @asset } + end + end + + # GET /assets/new + # GET /assets/new.xml + def new + @asset = Asset.new + + respond_to do |format| + format.html # new.html.erb + format.xml { render :xml => @asset } + end + end + + # GET /assets/1/edit + def edit + @asset = Asset.find(params[:id]) + end + + # POST /assets + # POST /assets.xml + def create + @asset = Asset.new(params[:asset]) + + respond_to do |format| + if @asset.save + flash[:notice] = 'Asset was successfully created.' + format.html { redirect_to(@asset) } + format.xml { render :xml => @asset, :status => :created, :location => @asset } + else + format.html { render :action => "new" } + format.xml { render :xml => @asset.errors, :status => :unprocessable_entity } + end + end + end + + # PUT /assets/1 + # PUT /assets/1.xml + def update + @asset = Asset.find(params[:id]) + + respond_to do |format| + if @asset.update_attributes(params[:asset]) + flash[:notice] = 'Asset was successfully updated.' + format.html { redirect_to(@asset) } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @asset.errors, :status => :unprocessable_entity } + end + end + end + + # DELETE /assets/1 + # DELETE /assets/1.xml + def destroy + @asset = Asset.find(params[:id]) + @asset.destroy + + respond_to do |format| + format.html { redirect_to(assets_url) } + format.xml { head :ok } + end + end +end -- cgit v1.3