Model/controller naming convention and where to put non-model code

J Jon Tara 3 years 7 months ago
4 0 0

I was cleaning-up our app to move some of the plethora of files that we have collected in the app/helpers directory to more appropriate directories. app/helpers owes it name to Rhodes' Ruby on Rails inspiration. In Rails, the helpers directory is specifically meant for controller helpers.
I'm sure many of you have mis-used (I think mis-used...) this directory to collect miscellaneous code. I know I have! So, for example, I have created some additional directories, such as model_mixins, library_extensions, etc.
Rhodes documentation is not at all clear about how Rhodes finds models and controllers. It is by naming convention, but the naming convention is not really clearly spelled-out. I had made an incorrect assumption, for example, that a directory starting with a capital letter designated a model. Apparently not true.
APPARENTLY it simply looks for directories directly under app. If that directory has a file in snake-case with the same name as the directory (which might be CamelCase or snake_case), and an .rb extension, then it is assumed to be a model.
As well, if a file is found that has a snake-case equivalent of the directory name, appended with_controller.rb, or else if there is a file in the directory called controller.rb, then it is considered a controller.
You do not have to have a model in order to have a controller, BTW!
I created a directory called ceas_api assuming it would not be seen as a model. However, it is, because it happens to contain a file called ceas_api.rb.
What is the recommended way to add and organize non-model code in Rhodes? I presume second-level directories off if helpers would be OK, for example. (But I would not be surprised if there were a problem if you should happen to create controller.rb, helpers_controller.rb, or helpers.rb in the app/helpers directory!)

CONTACT
Can’t find what you’re looking for?