class ImagesController < ApplicationController # This example does not handle all of the ins and outs of # allowing someone to 'replace' a file by edit/update. # That's a sticky problem that would only cloud # the concepts we're demonstrating here. # GET /images # GET /images.xml def index @images = Image.top_level.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @images } end end # GET /images/1 # GET /images/1.xml def show @image = Image.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @image } end end # GET /images/new # GET /images/new.xml def new @image = Image.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @image } end end # POST /images # POST /images.xml def create @image = Image.new(params[:image]) respond_to do |format| if @image.save format.html { redirect_to(@image, :notice => "Image was successfully created.") } format.xml { render :xml => @image, :status => :created, :location => @image } else format.html { render :action => "new" } format.xml { render :xml => @image.errors, :status => :unprocessable_entity } end end end # DELETE /images/1 # DELETE /images/1.xml def destroy @image = Image.find(params[:id]) @image.destroy respond_to do |format| format.html { redirect_to(images_url) } format.xml { head :ok } end end end