I''d like to organise my active records into modules but can''t
get the
associations to work. The doc says that associations within the same
module should work. I''ve tried using the class_name option too but
still
doesn''t work.
Can anyone help?
For example
module Mod1
class Animal < ActiveRecord::Base
has_many :dogs, :class_name => "Mod1::Dog"
end
class Dog < ActiveRecord::Base
belongs_to :animal, :class_name => "Mod1::Animal"
end
end
--
Posted via http://www.ruby-forum.com/.
When I call animal.dogs I get "uninitialized constant Dog" Garz wrote:> I''d like to organise my active records into modules but can''t get the > associations to work. The doc says that associations within the same > module should work. I''ve tried using the class_name option too but still > doesn''t work. > Can anyone help? > > For example > module Mod1 > class Animal < ActiveRecord::Base > has_many :dogs, :class_name => "Mod1::Dog" > end > class Dog < ActiveRecord::Base > belongs_to :animal, :class_name => "Mod1::Animal" > end > end-- Posted via http://www.ruby-forum.com/.