Superclass mismatch with nested POROs with "Model::Object" constant definition syntax #141

Closed
henrik opened this Issue Sep 18, 2013 · 4 comments

Comments

Projects
None yet
2 participants
Contributor

henrik commented Sep 18, 2013

If I have an app/models/voucher.rb containing an ActiveRecord model, and also a plain Ruby object in app/models/voucher/foo.rb, and if I nest modules like:

class Voucher
  class Foo
  end
end

Then I get "Unable to annotate voucher.rb: superclass mismatch for class Voucher"

If I instead do

class Voucher::Foo
end

it works fine. I'd rather use the former syntax since it has less surprising constant lookup and is easier to unit test.

Owner

ctran commented Sep 18, 2013

There is a semantic difference between the 2 examples, isn't there?

Contributor

henrik commented Sep 18, 2013

Yeah, the two forms definitely behave differently in different situations. Different constant lookup, different behavior depending on load order etc.

I would guess this is either about foo.rb being loaded first, so voucher.rb can't then be loaded due to the mismatch (in which case the fix would be to address that load order); or that it tries to annotate foo.rb without having loaded voucher.rb first (in which case the fix would probably involve loading both files).

@ctran ctran pushed a commit that referenced this issue Feb 26, 2014

Cuong Tran Fix the conversion from file path to class name which should fix #125
…and #141
8056ecf
Owner

ctran commented Feb 26, 2014

I fixed this problem in the develop branch.

ctran closed this Feb 26, 2014

ctran added the bug label Feb 26, 2014

ctran added this to the 2.6.3 milestone Feb 26, 2014

Contributor

henrik commented Feb 26, 2014

Thank you!

ctran self-assigned this Feb 27, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment