guidelines for where to put classes in Rails apps that don't fit anywhere

前端 未结 5 1658
忘掉有多难
忘掉有多难 2020-12-24 01:28

I\'m wondering if there are any best practices about where to put non-standard Ruby files in Rails apps, those that don\'t fit in any of the default directories (contr

5条回答
  •  执念已碎
    2020-12-24 01:47

    I place any model classes (like STI subclasses) in apps/models. I place my other classes in lib, as it seems to be the best place to put them. It's easy for me to know where to look. It's also easier for me to group my tests since my model classes are all in one place.

    Convention-wise I'm loathe to put helper classes in app/models. If they're presenter classes they belong in the app/helpers. If they're not then lib seems to be the best place for them.

提交回复
热议问题