Performance: Why controllers handle requests
MEDIUM IMPACT
This affects how quickly the server processes incoming requests and prepares responses, impacting the time before the browser receives content.
class UsersController < ApplicationController def show @user = User.find(params[:id]) render json: @user end end
class UsersController < ApplicationController def show @user = User.all render json: @user end end
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Fetching all records in controller | N/A (server-side) | N/A | N/A | [X] Bad |
| Fetching only requested record | N/A (server-side) | N/A | N/A | [OK] Good |