Rails Best Practices

17 votes

11550 views

Use asset_host for production server

Use asset host for cookie-free domains for components, that make your components load faster.

Comments

flyerhzm

6 votes

12280 views

abuse content_for

Use content_for for grouping html contents like javascript and css

Comments

by jvnill
jvnill

5 votes

17530 views

hjuskewycz

16 votes

15461 views

DRY your database.yml

Use YAML's anchor and reference syntax to DRY up your database.yml file.

Comments

by eric
eric

3 votes

3219 views

Use pickle & ur choice factory for data setup in ur cucumber features (revised)

Data setup is sometimes painful in features writing for cucumber. Use pickle & factory of ur choice to make it less painful.

Comments

by ngty
ngty

9 votes

3118 views

Use 'Background' to consolidate common steps in a feature

Very often, we tend to repeat a number of common steps in all scenarios within a feature, to dry things up, as well as improve readability (helping reader to better focus the intent of each scenario), we can use 'Background'.

Comments

by ngty
ngty

5 votes

3569 views

Use nested step to improve readability of ur scenario

When a scenario has too many steps, it becomes hard to read & follow. Using nested step helps to clean up the scenario, & helps promote reusability of groups of steps, think of it as code refactoring.

Comments

by ngty
ngty

37 votes

8153 views

Double-check your migrations

When you generate a new migration, try it forwards and backwards to ensure it has no errors

Comments

jaimeiniesta

-4 votes

3326 views

Writing specs for 3rd party declaratives

Using declaratives (eg. acts_as_authentic) provided by external libs is unavoidable in building a rails application. But testing 3rd party libs is surely not part of our work, yet how do we rest assured that these declaratives are called ??

Comments

by ngty
ngty

-1 votes

4485 views

Write ur own spec macros

Macro-writing is a great way to keep ur specs beautiful, compact & readable, & keeps specs writing fun. Macro-writing isn't rocket science, everyone can do it (almost, i think).

Comments

by ngty
ngty