- Use 2 spacing indentation
- Use snake case
- use all caps on constant
- space around operator
- no messy space around (,[,{,},],),!,?,...
- comment wisely
- empty line between different logic
- indent wisely
- align element of array or hash
- Prefer "unless" than if !
- Use one line "if" or "unless" when only has 1 line code
- avoid 1 single line method
- put . at the first line when chaining method goes too long
- use "each" instead of "for"
- use ternary if only has 1 line code
- don't mix hash rocket with literal hash
- prefer find instead of where(conditions).first
- use where.not (rails 4) instead of query comparation
- use understandable word
- remove dead code , don't comment it
- config
- model
- controller
- view
- AR
- database migration
- I18n
- assets
- mailer and jobs
- put constant and gem config in config
- add / remove assets that you want to precompile
- create staging.rb for staging
- use correct routes method (GET, POST, PUT, DELETE)
- use resource and nested resources wisely
- use collection and member for routes
- Make it fat and clean
- separate to another method if it's too long
- DRY or make it as module
- use scope
- Make it thin and understandable
- Keep application controller clean, use it for global only
- Keep simple logic, if it's too complicated move to model
- use before_action
- follow REST
- use private and public method
- Do not change variable in view
- minimal or no logic
- move logic to helper
- separate from assets as much as possible
- use partial for shared views
- don't use too much partial it will slow down your rendering
- Avoid altering default method
- Group your method e.g. validation, scopes, dll
- Use custom validator
- Avoid sql injection vulnerability (string interpolation)
- use find_each for big records
- Always use migration
- Add index if needed
- When it's deployed, don't up/down old migration
- Make it hierarcy
- Separate for each language
- Use your own asset grouping (don't require all)
- Use gemified version
- Precompile only css / js you need
- Name your mailer class with suffix Mailer
- Place your long process in background
- Sending email should be in background
- Style should be inline
Made with Slides.com