Ruby on Rails
Friday, September 28, 2018
Yeah, I created a Rails 3 and Rails 4 project. Rails 3 doesn't support #cache_key on collection, and Rails 4 uses each individual element to create a cache key.
I set up byebug and traced the #cache view helper. The reason the relation is being loaded is because the helper eventually calls #to_a on the relation, which of course results in the query being executed.
Looks like the best solution is using #cache_key directly.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5421611e-cbc9-4bda-9b92-fc5ae8238bdd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment