Neil Neil - 2 months ago 16
Ruby Question

Convention for naming PORO Models in Rails?

In an attempt to be more object-oriented, I find myself creating more POROs (Plain-old_ruby-objects). In rails, this simply means that the model class does not inherit from

and thus this model is not backed by a database table.

Lets say I have an app with hundreds of models. It would be nice if there was some naming convention of PORO models so that those PORO models can be quickly identified instead of having to open up each of their files and notice that they do not inherit from

I could not find a naming convention for this. Does one exist in the rails community? If not, suggestions are welcome.


What I ended up doing was creating a subdirectory in my app/models directory called: poros.

In order to make those files within that poros subdirectory available within the load path, I had to go into config/application.rb and add this line:

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

Now I can access those POROs just like I can with any of the Models.