Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I implement business logic layer in Rails? And where should I put that code?

I read "Enterprise Rails" (http://oreilly.com/catalog/9780596515201) The author suggests to have two subfolders named logical, physical under the models folder. It sounds like a good idea to organize the code. It will also allow to have a business layer. I just want to know how rails community feels about this. Is it a good idea to have a separate logic layer?

like image 309
Metin Avatar asked Dec 05 '25 00:12

Metin


1 Answers

Sometimes I use a "service" layer along the model and controller ones.

I just add it to the autoload_path.

But most of the time, I manage to set the logic into models, or stateless models. So it goes directly into the models folders.

like image 193
Pasta Avatar answered Dec 06 '25 14:12

Pasta