w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Could/should I organize my 30 classes in folders?

Naturally it is possible and it is advised to do so - code organization is a key to any successful project.

In rails each folder within any load_path defines an (initially) empty module, so remember that classes within a file subfolder/my_class.rb are expected to be named Subfolder::MyClass rather than MyClass - otherwise rails will not be able to find them.

Another way would be to add your folders to load_paths, however personally I much rather prefer to have my scoped classes to be, well, scoped within a modules.

To this you'll need to add the following to your config/application.rb:

config.load_paths << config.root.join 'app', 'models',

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.