Skip to content

Instantly share code, notes, and snippets.

@rsl
Created September 23, 2008 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsl/12303 to your computer and use it in GitHub Desktop.
Save rsl/12303 to your computer and use it in GitHub Desktop.
class FoosController < ApplicationController
def create
@foo = Foo.new(params[:foo])
respond_to do |format|
if @foo.save
flash[:notice] = 'Foo was successfully created.'
format.html { redirect_to(@foo) }
format.xml { render :xml => @foo, :status => :created, :location => @foo }
else
format.html { render :action => "new" }
format.xml { render :xml => @foo.errors, :status => :unprocessable_entity }
end
end
end
def update
@foo = Foo.find(params[:id])
respond_to do |format|
if @foo.update_attributes(params[:foo])
flash[:notice] = 'Foo was successfully updated.'
format.html { redirect_to(@foo) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @foo.errors, :status => :unprocessable_entity }
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment