Pito Salas wrote in post #955126: > I have a few "outlier" cases of ruby files used by my rails app and am > trying to decide where to put them. > > 1. Models that are not ActiveRecord models. Suggestion: app/models
There is a pernicious assumption among many Rails developers that models have to be ActiveRecord subclasses, and that there's something abnormal if they're not. Nothing could be further from the truth. The term "Model", in MVC nomenclature, refers to a class that represents an actual domain object. Where a model class stores its data (in the DB or otherwise), and whether it uses ActiveRecord to do so, are implementation details that have no bearing on whether the class is in fact a model or whether it belongs in app/models. Anything model-like, whether or not it talks to the DB, goes in app/models. > > 2. Utility classes which are invoked by the application during normal > operation. Not sure between app/utility - on the theory that they are > part of the application, or lib/utility - on the theory that they are > not rails classes at all. lib doesn't imply that something is "not a Rails class". Utility classes (that are not models) go in lib. I don't see what the utility directory inside there gains you; lib is already utilities. > > Other then aesthetics, there might be issues regarding rails finding and > loading the classes, or perhaps relating to development vs. production > mode, or other trade offs that I don't see. I suspect these are topics > of debate and taste, so I am looking more for some kind of authoritative > link or source. The above recommendations are more or less the standard Rails way. If you introduce additional directory nesting, then you need to namespace your classes correspondingly if you want Rails to autoload them. > > Thanks for your pointers! > > - Pito Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.