So I have a method and corresponding partial for including a set of random photos in the sidebar of certain areas of our site.
Right now I have a random_photos
method in ApplicationController set with a before_filter
.
That works in the sense that it makes the contents of the random_photos
method available wherever I need it, but it also unnecessarily executes some complex SQL queries when I don't know it too (ie, when I don't need to access those random photos).
So, how can I limit the accessing of the random_photos
method to only when I really need it?