This plugin no longer works with Rails 2.1 and has subsequently been discontinued.
As an alternative, try placing this in application.rb:
helper_method :read_fragment_or_cache
def read_fragment_or_cache(opts)
#puts "read_fragment_or_cahce called. opts = #{opts.inspect}"
# Check to see if key has expired
return nil unless opts[:key]
key = opts[:key]
expire_at = opts[:expire_at] || Time.now
fragment = Rails.cache.read(key, :raw => true)
#fragment = read_fragment(key, {:expire_at => expire_at})
if fragment.nil?
puts "\n\n Fragment NOT FOUND for key: #{key}\n"
# Render whatever should be rendered by the render options to a string for caching.
fragment = render_to_string(opts[:render])
Rails.cache.write(key, fragment, :raw => true)
#result = write_fragment(opts[:key], fragment)
else
puts "\n\n Fragment WAS INDEED found for key: #{key}\n"
end
return fragment
endThen you can define cache helper methods (in application.rb, for example) like:
helper_method :cached_popular_this_week
def cached_popular_this_week
fragment = read_fragment_or_cache :key => "home/popular_this_week",
:expire_at => 1.hour.ago,
:render => {:partial => "shared/popular_this_week"}
return fragment
endAnd simply call them in your views with:
There might be better ways to do all this. Hopefully this is of some help though if you are migrating to Rails 2.1 and beyond.
Open Hub computes statistics on FOSS projects by examining source code and commit history in source code management systems. This project has no code locations, and so Open Hub cannot perform this analysis
Is this project's source code hosted in a publicly available repository? Do you know the URL? If you do, click the button below and tell us so that Open Hub can generate statistics! It's fast and easy - try it and see!
This Project has No vulnerabilities Reported Against it
Did You Know...
...
there are over 3,000 projects on the Open Hub with security vulnerabilities reported against them
...
search using multiple tags to find exactly what you need
...
65% of companies leverage OSS to speed application development in 2016
...
by exploring contributors within projects, you can view details on every commit
they have made to that project
No code available to analyze
Open Hub computes statistics on FOSS projects by examining source code and commit history in source code management systems. This project has no code locations, and so Open Hub cannot perform this analysis
Is this project's source code hosted in a publicly available repository? Do you know the URL? If you do, click the button below and tell us so that Open Hub can generate statistics! It's fast and easy - try it and see!
This site uses cookies to give you the best possible experience.
By using the site, you consent to our use of cookies.
For more information, please see our
Privacy Policy