Rails Best Practices
When you want to associate a model to many association models by checkbox on view, you should take advantage of model.collection_model_ids to reduce the code in controller.
In MVC model, controller should be simple, the business logic is model's responsibility. So we should move logic from controller into the model.implemented
Sometimes you will build a complex model with params, current_user and other logics in controller, but it makes your controller too big, you should move them into model with a factory methodimplemented
Use model callback can avoid writing some logic codes in controller before or after creating, updating and destroying a model.
Do not assign the model's attributes directly in controller. Add model virtual attribute to move the assignment to model.implemented
You can use scope access to avoid checking the permission by comparing the owner of object with current_user in controller.implemented
Use model association to avoid assigning reference in controller.implemented