I was playing with REST and respond_to and found a bug. I can't tell if it's a safari or rails bugs but maybe you can tell me more about the issue :
# projects_controller.rb
def close
respond_to do |format|
if Project.find(params[:id]).update_attribute(:closed, true)
flash[:notice] = "Project was successfully closed."
format.xml { head :ok }
else
flash[:notice] = "Error while closing project."
format.xml { head 500 }
end
format.html { redirect_to projects_url }
end
end
# routes.rb
map.resources :projects, :member => { :close => :post }
map.resources :projects do |projects|
projects.resources :iterations
end
# url : http://localhost:3000/projects/1;close
This page contains the following errors:
error on line 1 at column 1: Extra content at the end of the document
Below is a rendering of the page up to the first error.
# So it doesn't work in safari but in firefox it's ok, the page is rendered
# I can make it work in safari too if I change the controller for :
def close
respond_to do |format|
if Project.find(params[:id]).update_attribute(:closed, true)
flash[:notice] = "Project was successfully closed."
format.html { redirect_to projects_url }
format.xml { head :ok }
else
flash[:notice] = "Error while closing project."
format.html { redirect_to projects_url }
format.xml { head 500 }
end
end
end
# But it's not DRY anymore