1 class StatesController < ApplicationController
5 @states = State.find(:all)
8 format.html # index.html.erb
9 format.xml { render :xml => @states }
16 @state = State.find(params[:id])
18 respond_to do |format|
19 format.html # show.html.erb
20 format.xml { render :xml => @state }
29 respond_to do |format|
30 format.html # new.html.erb
31 format.xml { render :xml => @state }
37 @state = State.find(params[:id])
43 @state = State.new(params[:state])
45 respond_to do |format|
47 flash[:notice] = 'State was successfully created.'
48 format.html { redirect_to(@state) }
49 format.xml { render :xml => @state, :status => :created, :location => @state }
51 format.html { render :action => "new" }
52 format.xml { render :xml => @state.errors, :status => :unprocessable_entity }
60 @state = State.find(params[:id])
62 respond_to do |format|
63 if @state.update_attributes(params[:state])
64 flash[:notice] = 'State was successfully updated.'
65 format.html { redirect_to(@state) }
66 format.xml { head :ok }
68 format.html { render :action => "edit" }
69 format.xml { render :xml => @state.errors, :status => :unprocessable_entity }
75 # DELETE /states/1.xml
77 @state = State.find(params[:id])
80 respond_to do |format|
81 format.html { redirect_to(states_url) }
82 format.xml { head :ok }