I moved some files into subfolders within my app/models directory and added those directories in the config.load_paths in config/environment.rb:
config.load_paths += Dir["#{Rails.root}/app/models/extras"]
within app/models/extras I've got a few ActiveRecord models, for instance say:
app/models/extras/blog_post.rb
class BlogPost < ActiveRecord::Base
has_many :comments
end
app/models/extras/comment.rb
class Comment < ActiveRecord::Base
belongs_to :blog_post
end
Now when I call a page (ie. /blog_posts/) where only BlogPosts are shown (without loading the comments association) everything works fine But if I call a page (ie. /blog_posts/1) where the comments are included in the queries (like, BlogPost.find(1, :include => :comments), I get the following error:
Expected .../app/models/extras/comment.rb to define Extras::Comment
Now everything works fine in production mode, but not in development.. Anyone has a fix or a solution for this?