Performance: Model generation
MEDIUM IMPACT
Model generation affects the initial load time and database interaction efficiency of a Rails application.
rails generate model User name:string email:string
# Add index on email in migration and only necessary callbacks and validationsrails generate model User name:string email:string
# Then manually add many callbacks and validations without indexing| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Model with no indexes and many callbacks | N/A (backend) | N/A | Increases server response time delaying paint | [X] Bad |
| Model with indexes and minimal callbacks | N/A (backend) | N/A | Faster server response improves paint timing | [OK] Good |