Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #controllers/user_controller.rb
- class UserController < ApplicationController
- def index
- users = User.includes(:posts)
- json = Rails.cache.fetch(User.cache_key(users)) do
- users.to_json(include: :posts)
- end
- render json: json
- end
- end
Add Comment
Please, Sign In to add comment