Models in sub-folders in Rails 3

I have a Rails 2 project in which models are in sub-folders, but not in
a name space


class Post < ActiveRecord::Base

The controllers are also in sub-folders, but are name spaced (views also
in a corresponding sub_folder).


class SubFolder::PostsController < ApplicationController

This works fine, but I want to move on to Rails 3, and it all falls

In application.rb I have

    config.autoload_paths += Dir["#{config.root}/app/models/**/"]

So Rails should be able to find the models. However running tests (which
are subfoldered in an analogous way), I get

LoadError: Expected R:/test3/app/models/sub_folder/post.rb to define

So okay, suppose I name-space my models? Now I get:

LoadError: Expected R:/test3/app/models/sub_folder/post.rb to define

Taking the model out of it sub-folder does allow the tests to pass, but
my real project has over 30 models, and I really do want them to be
structured somehow.

Running on Rails version 3.2.2, with Ruby 1.9.2, on JRuby 1.6.7 by the
way, and all the above are from a simple test project that I created
just for this purpose; no custom code except as noted above. I have
found several web pages about this issue, but they just indicate the
config.autoload_paths bit should solve the problem; am I missing
something simple here?

  In model i.e app/models/sub_folder/posts.rb you need to specify
sub_folder namespace to it then it will work.

class SubFolder::Post < ActiveRecord::Base

whenever u fire any query you need to specify

Then only it will work .