Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9529: id_from_response.diff

File id_from_response.diff, 0.7 kB (added by zippy, 10 months ago)

patch file to fix responses without a "Location" header

  • vendor/rails/activeresource/lib/active_resource/base.rb

    old new  
    809809 
    810810      # Takes a response from a typical create post and pulls the ID out 
    811811      def id_from_response(response) 
    812         response['Location'][/\/([^\/]*?)(\.\w+)?$/, 1] 
     812        if response.has_key?('Location') 
     813          response['Location'][/\/([^\/]*?)(\.\w+)?$/, 1] 
     814        else 
     815          nil 
     816        end 
    813817      end 
    814818 
    815819      def element_path(options = nil)