-
Be restful
-
Put view partials in proper resource (table partial, not table body)
-
Namespace a lot, use lib a lot, but don't put app (eg AR models) stuff in lib
-
Models should not use change itself in callbacks; Use services, strategies, queries, have a clear dependency hirarchy
-
Limit the use of validation (defaults?), they are only for UI purposes, (almost) always add relative DB constraints
-
DB foreign_keys, unique indexes, null with defaults
-
No SQL outside of the model
-
Write extra models (or Query objects?) to connect models
-
Write non-AR models
-
Write your own state machine, not in the model
-
Always inject time (never have Time.now in models)
-
You only need two workers, call services (same in whenever and rake tasks)
-
Dependency direction (not everything in User), avoid
has_many
-
Avoid monolith, have several apps, don't make everything a microservice
-
When doing unrelated things (no dependencies), extract into microservices (lambdas for image processing etc)
-
Don't customise devise and gems much at all
-
ActiveAdmin only for devs
-
Keep it simple, focus on main app reason, use saas like gravatar
-
Wrap Log with exception
-
Re-raise your exceptions, but be generic
-
Test services, models etc in Ruby, Frontend tests in jest.
- OO Tell don't ask
- Fail early, confident ruby (
save!
) - 2 words in the dictionary, 2 in the code, eg:
first_name
- Don't name implementations, eg:
Rollbar, AWS, Braintree
, useLogService, CloudService, PaymentService
- Service: for actions, DB modifications, emails etc
- Strategy: functions without side effects
- Query? no side effects, use a joining model for 2 models, query for 3+ put your method it in the model it returns (eg UserQuery)
- Decorator?? NO
- Rails for b2b, public face in React?