命名空间类加载顺序问题

时间:2018-08-30 06:36:27

标签: ruby-on-rails ruby ruby-on-rails-4

我有两个命名空间的类。其中一个继承其他。

目录结构如下:

app
└── clients
    └── test
        ├── a
        │   └── calls
        │       └── reports.rb
        ├── b
        │   └── calls
        │       └── reports.rb
        ├── c
        │   └── calls
        │       └── reports.rb
        ├── a.rb
        ├── b.rb
        └── c.rb

这是代码段:

# app/clients/test/c/calls/reports.rb
module Test::C::Calls
  class Reports < Test::B::Calls::Reports
  end
end

# app/clients/test/b/calls/reports.rb
module Test::B::Calls
  class Reports < Test::A::Calls::Reports
  end
end

# app/clients/test/a/calls/reports.rb
module Test::A::Calls
  class Reports
  end
end

# app/clients/test/a.rb
class Test::A 
end

# app/clients/test/b.rb
class Test::B < Test::A  
end

# app/clients/test/c.rb
class Test::C < Test::B  
end

在Rails控制台上,如果在Test::B::Calls::Reports之前调用Test::C::Calls::Reports,则Test::C::Calls::Reports返回Test::B::Calls::Reports,但是反之亦然。

我正在使用Rails 4.1.4。

我无法找出问题。

0 个答案:

没有答案
相关问题