]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/old_way_controller.rb
Rework expansion of HTTP status code to work with rails 3
[rails.git] / app / controllers / old_way_controller.rb
index 96c88d492dc777f7bb5f61c63dea885ddf83a462..5ea1a0497d7cba35a85fe8a0c03eb3de6fc6cf41 100644 (file)
@@ -18,18 +18,15 @@ class OldWayController < ApplicationController
   end
   
   def version
-    old_way = OldWay.find(:first, :conditions => {:id => params[:id], :version => params[:version]} )
-    if old_way.nil?
-      # (RecordNotFound is not raised with find :first...)
+    if old_way = OldWay.where(:id => params[:id], :version => params[:version]).first
+      response.last_modified = old_way.timestamp
+
+      doc = OSM::API.new.get_xml_doc
+      doc.root << old_way.to_xml_node
+
+      render :text => doc.to_s, :content_type => "text/xml"
+    else
       render :nothing => true, :status => :not_found
-      return
     end
-    
-    response.headers['Last-Modified'] = old_way.timestamp.rfc822
-    
-    doc = OSM::API.new.get_xml_doc
-    doc.root << old_way.to_xml_node
-    
-    render :text => doc.to_s, :content_type => "text/xml"
   end
 end