Rails Best Practices

Hi all,

Last month, there's a Kungfu Rails Conf in Shanghai, China. And
there's an awesome presentation "Rails Best Practices"
http://www.slideshare.net/ihower/rails-best-practices . Yehuda Katz
also likes this presentation.

Now I'm writing a gem to automatic practices check according to this

The project repository is here: http://github.com/flyerhzm/rails_best_practices
And wiki pages are here: http://wiki.github.com/flyerhzm/rails_best_practices

It's a code static parser tool like roodi, flog and flay. You can use
it just type "rails_best_practices ." in the root directory of your
rails app.

The gem is not complete yet, finished about 70%. But you can use it
now, just some check lists are not implemented yet.

Last, I will paste all of the check lists, these check lists are
described detailed in wiki pages:

    * Lesson 1. Move code from Controller to Model
         1. Move finder to named_scope
         2. Use model association
         3. Use scope access
         4. Add model virtual attribute
         5. Use model callback
         6. Replace Complex Creation with Factory Method
         7. Move Model Logic into the Model
         8. model.collection_model_ids (many-to-many)
         9. Nested Model Forms (one-to-one)
        10. Nested Model Forms (one-to-many)

    * Lesson 2. RESTful Conventions
         1. Overuse route customizations
         2. Needless deep nesting
         3. Not use default route

    * Lesson 3. Model
         1. Keep Finders on Their Own Model
         2. Love named_scope # same as Move finder to named_scope
         3. the Law of Demeter
         4. DRY: metaprogramming
         5. Extract into Module
         6. Extract to composed class
         7. Use Observer

    * Lesson 4. Migration
         1. Isolating Seed Data
         2. Always add DB index

    * Lesson 5. Controller
         1. Use before_filter
         2. DRY Controller

    * Lesson 6. View
         1. Move code into controller
         2. Move code into model
         3. Move code into helper
         4. Replace instance variable with local variable
         5. Use Form Builder
         6. Organize Helper files

Hope you like this gem

Richard Huang