dewski / json_builder

Rails provides an excellent XML Builder by default to build RSS and ATOM feeds, but nothing to help you build complex and custom JSON data structures. JSON Builder is here to help.
http://garrettbjerkhoel.com/json_builder/
MIT License
243 stars 52 forks source link

cache issue #37

Open jackbit opened 12 years ago

jackbit commented 12 years ago

How to implement cache fragment and action here? it seems the chache_action doesnt work for json_builder

jackbit commented 12 years ago

here's my script in controller:

caches_action :index, 
                        :cache_path => Proc.new { |c| "#{c.params[:category].to_s.gsub(/\W/,'_')}_#{c.params[:per_page]}_#{c.params[:page]}" }, 
                        :gzip => :best_speed, 
                        :if => Proc.new { |c| c.params[:category].to_s =~ /all/i }
The output .json seems work
Read fragment views/all_podcast_50_1.json (80.0ms)
Read fragment views/all_twitter_50_1.json (200.8ms)
But .json_builder doesnt work
  Rendered forecasts/index.json.json_builder (25813.2ms)
Completed 200 OK in 36093ms (Views: 25959.5ms)
  Rendered forecasts/index.json.json_builder (10930.8ms)
Completed 200 OK in 46551ms (Views: 11033.0ms)
dewski commented 12 years ago

Could you paste what the contents of forecasts/index.json.json_builder is?

gouthamvel commented 11 years ago

Is there a wiki on how to implement fragment cache with json_builder

scomma commented 11 years ago

I'm wondering about this as well. I guess one of us will have to dig into the source and figure out how to best implement this, but some clues will be very much appreciated.