Tag helper

11 votes

8844 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

Comments

by ihower
ihower

11 votes

18382 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.

Comments

flyerhzm

13 votes

9445 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.

Comments

by dbloete
dbloete

13 votes

13361 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

Comments

flyerhzm

26 votes

27953 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

Comments

flyerhzm