Rails: Creating subfolders in model?
- by keruilin
I'm going to have a ton of subclasses, so want to organize them under a subfolder called stream. I added the following line to the environment.rb so that all classes in the subfolder would be loaded:
Rails::Initializer.run do |config|
...
config.load_paths += Dir["#{RAILS_ROOT}/app/models/*"].find_all { |f| File.stat(f).directory? }
...
end
I thought this would solve the issue in which by convention the model class is namespaced into an according module. However, when I try to call one of the classes called stream in the stream folder, I get the following error:
NoMethodError: undefined method `new' for Stream:Module
from (irb):28
from /usr/local/bin/irb:12:in `<main>'
Here's the model for the parent and one child:
class Stream
end
class EventStream < Stream
end
Any idea what the issue is?