Tag rails2

14 votes

12285 views

Move finder to named_scope

Complex finders in controller make application hard to maintain. Move them into the model as named_scope can make the controller simple and the complex find logics are all in models.

implemented

Comments

by ihower
ihower

4 votes

7942 views

Overuse route customizations

According to Roy Fielding’s doctoral thesis, we should use restful routes to represent the resource and its state. Use the default 9 actions without overusing route customizations.

implemented

Comments

by ihower
ihower

4 votes

12383 views

Needless deep nesting

Some people will define 3 or more level nested routes, it's a kind of over design and not recommended.

implemented

Comments

by ihower
ihower

9 votes

6871 views

Not use default route if you use RESTful design

If you use RESTful design, you should NOT use default route. It will cause a security problem. I explain at http://ihower.tw/blog/archives/3265 too.

implemented

Comments

by ihower
ihower

7 votes

5584 views

Keep Finders on Their Own Model

According to the decoupling principle, model should do finders by itself, a model should not know too much about associations finders logic.

implemented

Comments

by ihower
ihower

5 votes

6568 views

Love named_scope

named_scope is awesome, it makes your codes much more readable, you can also combine named_scope finders to do complex finders.

Comments

by ihower
ihower

1 votes

3413 views

Check if external gem-dependent classes are defined

If you have to set some external gem's config options in /config/enviroment.rb, contain it within `if defined?` block

Comments

by bartosz
bartosz