Rails Best Practices 5: Optimize Migration

Logo devnterface d88f51727b3053dd3115e1ef9c566ad79b4c2edb3cd208c06345fc37058bebd9

Migrations, in my opinion, are one of the best things in Rails since these allow the creation and populating the database using ruby code without having to worry about which type of db run below. That said, even writing the migration is better to follow some best practices. 1. DB Index The first practice I strongly recommend is to define indices for the external keys and for all those columns on which you will make sort, search and groups. ...

Read more

Rails Best Practices 3: Increase Controller’s readability

Logo devnterface d88f51727b3053dd3115e1ef9c566ad79b4c2edb3cd208c06345fc37058bebd9

[POST UPDATE ON 19/07/2010 - 15:45] Continuing our analysis of the Rails Best Practices today we’ll see two other tricks to make more readable method of the controller.1. Methods within modelSuppose we have the classic user registry defined in such a way that an admin user can enable or disable other users.The deactivate method inside user Controller may be defined as follows:123456789101112131415161718class UserController < ApplicationController def deactivate ...

Read more