Created
September 11, 2009 19:03
-
-
Save coffeencoke/185509 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# PUT /buckets/Animals | |
# PUT /buckets/Animals.json | |
# Used for creating and updating buckets | |
# view the features located at /features/buckets.*.feature | |
# for details on the design of this method. | |
def update | |
@bucket = Bucket.find_or_new_by_name params[:id] | |
if @bucket.new_record? | |
if @bucket.save | |
respond_to do |format| | |
format.html do | |
flash[:success] = "Bucket was successfully created." | |
redirect_to @bucket | |
end | |
format.json{ render :json => '', :status => 201 } | |
end | |
else | |
respond_to do |format| | |
format.html{ render :action => :new } | |
format.json{ render :json => '', :status => 500 } | |
end | |
end | |
else | |
if @bucket.update_attributes(params[:bucket]) | |
respond_to do |format| | |
format.html do | |
flash[:success] = "Bucket was successfully updated." | |
redirect_to @bucket | |
end | |
format.json{ render :json => @bucket, :status => 200 } | |
end | |
else | |
respond_to do |format| | |
format.html{ render :action => :edit } | |
format.json{ render :json => '', :status => 500 } | |
end | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment