views:

22

answers:

1

Hay fellow developer,

When I invoke @chapter.articles, rails yields the following error:

uninitialized constant Sommaire::Chapter::Article

Event if I specify *:class_name => "Sommaire::Article"*, it yields:

uninitialized constant Sommaire::Chapter::Sommaire::Article

Since I'm relatively new to rails (3.0.0), this has lost me !

Thanks in advance for your help. JD

Below the code from the classes
in sommaire.rb

class Sommaire < ActiveRecord::Base
  has_many :chapters
end

in sommaire/chapter.rb

class Sommaire::Chapter < ActiveRecord::Base
  include ItemBase

  def self.table_name
    'sommaire_chapters'
  end

  belongs_to :sommaire
  has_many :articles, :class_name => "Sommaire::Article"
  validates_presence_of :title, :description

end

in sommaire/article.rb

class Sommaire::Article < ActiveRecord::Base

  include ItemBase

  def self.table_name
    'sommaire_articles'
  end

  belongs_to :chapter

end
A: 

It would be worth trying class_name => '::Sommaire::Article' (note preceding ::) to indicate that the Sommaire path is from the root namespace.

It is possible though that there is some conflict between having a Sommaire namespace and a Sommaire model in which case you may want to rename one or the other.

Shadwell
Once again the wisdom of the mighty elders has enlighten me.(I will also think about renaming the "Sommaire" pseudo namespace)
Jeremy David