2

What would be the way to do this in rails 4?

For Rails 3 this works:

config.autoload_paths += Dir[ Rails.root.join('app', 'models', '**/') ]

But in Rails 4 it fails complaining about namespacing non existent ( like app/models/users/credits.rb gives error

Unable to autoload constant User::Credits, expected
Waynn Lue
  • 11,344
  • 8
  • 51
  • 76
Rubytastic
  • 15,001
  • 18
  • 87
  • 175
  • See the "Update for Rails 4.1" section of the accepted anser at http://stackoverflow.com/questions/18934115/rails-4-organize-rails-models-in-sub-path-without-namespacing-models – Choylton B. Higginbottom Jan 07 '15 at 22:45

1 Answers1

0

I just ran into this problem and fixed it by adding this to application.rb.

config.autoload_paths += Dir[Rails.root.join('app', 'models', '{**}')]
Waynn Lue
  • 11,344
  • 8
  • 51
  • 76