Sha256: 128376f69821186c984cff9de57673b7825c7482d9cfa7902cdcba9d9a1505b2
Contents?: true
Size: 1.57 KB
Versions: 26
Compression:
Stored size: 1.57 KB
Contents
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
Version data entries
26 entries across 26 versions & 1 rubygems