Tag helper

9 votes

2 comments

3891 views

Move code into helper

According to MVC architecture, there should not be logic codes in view, in this practice, I will introduce you to move codes into helper.

implemented
by ihower
ihower

9 votes

4 comments

6082 views

Generate polymorphic url

If you want to generate different urls according to different objects, you should use the polymorphic_path/polymorphic_url to simplify the url generation.

flyerhzm

11 votes

10 comments

5067 views

Substituting before_filter :load_object

Instead of loading an object with a before_filter you can use a more intelligent helper_method to get the main object for the controller context.

by dbloete
dbloete

13 votes

6 comments

6218 views

Remove empty helpers

If you use rails generator to create scaffolds or controllers, it will also create some helpers, most of the helpers are useless, just remove them.

implemented
flyerhzm

11 votes

8 comments

6262 views

Not use time_ago_in_words

It's very common for a rails developer to use time_ago_in_words to display time like "5 minutes ago", but it's too expensive to calculate the time in server side, you should utilize client cpu to calculate the time ago.

implemented
flyerhzm
Fork me on GitHub