This project is archived and is in readonly mode.

#5699 ✓resolved
Matthijs Langenberg

Fix broken module namespacing in ActiveResource when using Ruby 1.9

Reported by Matthijs Langenberg | September 24th, 2010 @ 10:26 PM

Following namespacing use case is broken when using Ruby 1.9:

class Author < ActiveRecord::Base
end

module Api
  class Book < ActiveResouce::Base
  end
end

Let's say XML contains <book><author><name>John</name></author>....

Api::Book.first.author.class.to_s #=>
  Ruby 1.8.7: "Api::Book::Author" (namespaced, correct),
  Ruby 1.9: "Author" (toplevel, broken)

This is caused by differences in the implementation of mod.const_get? and mod.const_defined? between Ruby 1.8 and 1.9.

Also, see http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l33 for more background information.

This patch fixes this by passing the 2nd inherit argument as false for mod.const_get? and mod.const_defined? when trying to lookup an existing resource, in the case of Ruby 1.9.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages