views:

42

answers:

1

Within my Rails application I have a module defined this way:

module WhateverModule
  class WhateverClass
    ...
  end
end

This file (whatever_class.rb) is located under /app/models/whatever_module

const_missing is being overriden by Rails and despite I did some workarounds, involving initializers, I wish I could make it in a better way.

My aim is to get a WhateverModule::Foo (Foo being undefined) to be resolved by a custom const_missing method.

Any help will be greatly appreciated. Thanks in advance!!

A: 

The following seems to work fine for me in Rails 2.2.2

module WhateverModule
  def self.const_missing(c)
     # handle missing constant
  end
end
Harish