mardi 12 mai 2015

Ruby on Rails ActiveRecord Conventions

We're trying to establish best practices for a project and we're discussing where SQL and ActiveRecord methods should be placed.

My understanding is that you want to keep as much logic out of controller as possible. I think we agree on complex SQL queries belonging to models, but we are disagreeing on where simple AR methods should live, whether in the controller or in the model.

So with something simplistic like:

client = Client.find(10)

Would it ideally live in a model or controller? I understand that it may not make much/any difference, and the answer will be doesn't matter, but any insight into the question would be great.

Aucun commentaire:

Enregistrer un commentaire