I am using rails v3.2.2. I have two classes stated like the following:
# app/models/article/category/article_relationship.rb
class Article::Category::ArticleRelationship < ActiveRecord::Base
...
end
# app/models/comment/category/article_relationship.rb
class Comment::Category::ArticleRelationship < ActiveRecord::Base
...
end
# app/models/article/category.rb
class Article::Category < ActiveRecord::Base
...
end
# app/models/article.rb
class Article < ActiveRecord::Base
...
end
If in my view file I state
::Article::Category::ArticleRelationship
# or
Article::Category::ArticleRelationship
I get the following error:
NameError
uninitialized constant Category::ArticleRelationship
How can I solve the problem?
UPDATE
I discovered the problem occurs "mostly" when I state at the same time more than one namespaced class in the same file like, for example:
::Article::Category::ArticleRelationship
::Article::Category
# or
::Comment::Category::ArticleRelationship
::Article::Category
# or
::Article::Category
::Article::Category::ArticleRelationship
# or
::Article::Category::ArticleRelationship
Article::Category
# or
Article::Category::ArticleRelationship
::Article::Category
# or
::Article::Category::ArticleRelationship
::Article
# or
::Article
::Comment::Category::ArticleRelationship
# or
...
and it seems to happen randomly!
Note: This question is "inspired" by the answer of @Frederick Cheung to this question.