I have a class Semester
that will be used to query a database using ActiveRecord
to get the current semester, previous semester, and next semester by date. However, I won't have a controller or route for this, so I can't put it into the app/models/
directory, but where should I put it? A concerns
directory, or the lib
directory?
Asked
Active
Viewed 46 times
0

josh
- 9,656
- 4
- 34
- 51
1 Answers
2
A model doesn't necessarily need to be part of a full resource, with route and controller : if it maps some kind of data entity, it's a model - especially if it's a subclass of active_record.
So app/models/
is the perfect place for your Semester
model.

kik
- 7,867
- 2
- 31
- 32
-
1See also http://stackoverflow.com/questions/1068558/oo-design-in-rails-where-to-put-stuff – Peter Alfvin Sep 12 '13 at 17:16
-
@PeterAlfvin : always useful, but not sure it applies here : the problem was not that much having load of logic in models, but more the misinterpretation that any model should be part of a resource with routes and dedicated controller. – kik Sep 12 '13 at 17:19
-
I agree that your answer was sufficient to address his specific question (and I just upvoted it), but because he had this question/misunderstanding, I though the other question (and the 175-upvoted answer http://stackoverflow.com/a/1071510/1008891) in particular, might be useful. That's why I said "see also". – Peter Alfvin Sep 12 '13 at 17:30