diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2017-07-23 16:58:09 -0500 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2017-07-23 16:58:09 -0500 |
commit | 2bbfaf0c9f6ad23cb2c64a917848ca180917ebe2 (patch) | |
tree | 3ebc65daf6d6bfd904a455afc8008478a2b01d55 | |
parent | e16d0c9ceacd771c99048385dc886c6026c7bc45 (diff) | |
download | rails-2bbfaf0c9f6ad23cb2c64a917848ca180917ebe2.tar.gz rails-2bbfaf0c9f6ad23cb2c64a917848ca180917ebe2.tar.bz2 rails-2bbfaf0c9f6ad23cb2c64a917848ca180917ebe2.zip |
Demonstrate preloading in example
-rw-r--r-- | README.md | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -66,6 +66,11 @@ class MessagesController < ApplicationController message.images.attach(params[:message][:images]) redirect_to message end + + def show + # Use the built-in with_attached_images scope to avoid N+1 + @message = Message.find(params[:id]).with_attached_images + end end ``` |