Created
September 23, 2008 15:19
-
-
Save rsl/12303 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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