Rails and Stuff at Abel killed Cain

Ruby on Rails and other Webdevelopment

Posts Tagged ‘ Quick ’

Guess you never had and never will have this issue!

Anyways, a note for me about rails complaining about a too long cache key like by caching a list fo products in an eshop.

so instead of e.g. the following pseudo fragment-cache code

1
2
- cache [ @products, "things_i_dont_own"] do
    = render :partial...

try, only if its a sequential list:

1
2
- cache [[ @products.first, @products.last], "things_i_dont_own"] do
    = render..

if its a random created list, maybe you want to map all ids, like

1
@products.map{|x| x.id}

if @products is a big list, try to create indiviual hashes instead and use sweepers.

regards!