I am using rails 3 and fragment cache. Here is my controller code(show method):
if request.format == 'pdf'
render pdf: @design.slug, layout: 'application'
else
**expire_fragment('design_printed_by')**
@design.add_evaluation(:viewed_count, 1, current_user) if current_user && !current_user.evaluated?(@design, :viewed_count)
respond_with @design
end
And here is my view file code(show.html.slim) :
- cache ['design_printed_by', @design], skip_digest: true do
= render partial: 'printed_by', locals: { design: @design }
But when i add new record, this record is not display on page. I don't know what i am missing.
Is there anything wrong with this code?
Check this link may it help you.
http://guides.rubyonrails.org/caching_with_rails.html#fragment-caching