News for hackers. Stuff that matters.
Re:Rails – The Missing Parts by troels on Monday March 03, 2014 @02:04PM (#7335654)
One thing I can't figure out is whether to place my service objects under `/app/models` or under `/lib`. There doesn't seem to be a clear consensus on this? I tend more towards the former, because autoload works better during development. Also, I consider them part of my domain model. What do you do?
Re:Rails – The Missing Parts by lengarvey on Monday March 03, 2014 @02:08PM (#7335679)
There's nothing stopping you from creating extra folders under /app to contain various types of service objects. Personally I have:

  /app/factories - for classes which create active record objects
  /app/services - for classes which do something I generally don't care about the return value of. Often perfect for background jobs.
  /app/decorators - most of these are Draper classes
  /app/forms - form objects
and a few others from various other gems.
Re:Rails – The Missing Parts by Legion on Monday March 03, 2014 @02:20PM (#7335777)

  /app/interactors
It's a trivial thing to add new folders like this to autoloading:

  # add to application.rb
  config.autoload_paths += %W(#{config.root}/app/interactors)
Re:Rails – The Missing Parts by nthj on Monday March 03, 2014 @02:40PM (#7335919)
Re:Rails – The Missing Parts by tomblomfield on Monday March 03, 2014 @02:31PM (#7335845)
Anything that is application-specific, we put in /app

Anything that's generic and re-usable, we put in /lib. This code is normally a prime candidate for gems - only very simple code stays in /lib for very long.

Re:Rails – The Missing Parts by rjspotter on Monday March 03, 2014 @04:11PM (#7336501)
I use /app/interactors or /use_cases (per some Uncle Bob talk about architecture). I don't consider them models in the 'Data Model' sense so I don't put them in /app/models
Re:Rails – The Missing Parts by bphogan on Monday March 03, 2014 @02:08PM (#7335680)
I have app/services and just add that in application.rb to the load path.
Re:Rails – The Missing Parts by te_chris on Monday March 03, 2014 @02:17PM (#7335755)
You don't even need to add that to the load path as of rails 4 - we have app/validators, app/services, app/forms, app/inputs etc etc, all autoloaded with no config.