Skip to content
This repository has been archived by the owner on Mar 1, 2018. It is now read-only.

Caching problem in PackageBranch:cached_available_updates #153

Open
mkuron opened this issue Aug 24, 2012 · 0 comments
Open

Caching problem in PackageBranch:cached_available_updates #153

mkuron opened this issue Aug 24, 2012 · 0 comments
Labels

Comments

@mkuron
Copy link
Contributor

mkuron commented Aug 24, 2012

The first request for the Available Package Updates widget after restarting the server works fine:

Started GET "/dashboard/widget/available_package_updates?_=1345806177829" for 127.0.0.1 at 2012-08-24 13:02:57 +0200
Processing by DashboardController#widget as JS
  Parameters: {"_"=>"1345806177829", "name"=>"available_package_updates"}
  Rendered widgets/_available_package_updates.html.erb (1895.5ms)
  Rendered dashboard/widget.js.erb (1898.0ms)
Completed 200 OK in 1934ms (Views: 1875.9ms | ActiveRecord: 31.1ms)

Subsequent requests however return a HTTP 500 error:

Started GET "/dashboard/widget/available_package_updates?_=1345806374208" for 127.0.0.1 at 2012-08-24 13:06:14 +0200
Processing by DashboardController#widget as JS
  Parameters: {"_"=>"1345806374208", "name"=>"available_package_updates"}
  Rendered widgets/_available_package_updates.html.erb (12.0ms)
  Rendered dashboard/widget.js.erb (12.6ms)
Completed 500 Internal Server Error in 37ms

ActionView::Template::Error (undefined method `icon' for :@relation:Symbol):
    11:                     <% packages.each do |package| %>
    12:                         <p>
    13:                             <%= image_tag(package.icon.url(:tiny), :class => "thumbnail", "data-package-branch-id" => package.package_branch_id) if package.icon %>
    14:                             <%= link_to "#{package.name}", package_path(package.to_params) %> 
    15:                             version 
    16:                             <%= link_to package.package_branch.version_tracker.version, macupdate_url(package) %> is now available!
  app/views/widgets/_available_package_updates.html.erb:13:in `block (2 levels) in _app_views_widgets__available_package_updates_html_erb___1114117588481770231_2507639700'
  app/views/widgets/_available_package_updates.html.erb:11:in `each'
  app/views/widgets/_available_package_updates.html.erb:11:in `block in _app_views_widgets__available_package_updates_html_erb___1114117588481770231_2507639700'
  app/views/widgets/_available_package_updates.html.erb:1:in `each'
  app/views/widgets/_available_package_updates.html.erb:1:in `_app_views_widgets__available_package_updates_html_erb___1114117588481770231_2507639700'
  app/views/dashboard/widget.js.erb:1:in `_app_views_dashboard_widget_js_erb___17472507496854109_2172550500'
  app/controllers/dashboard_controller.rb:10:in `widget'

I added a line containing logger.warn packages to app/views/widgets/_available_package_updates.html.erb to see where it's going wrong. On the first run, packages is [#<Package id: 10 ...>, #<Package id: 13 ...>, #<Package id: 21 ...>], on subsequent runs it's [#<Package id: 10 ...>, :@relation, nil].
Apparently there is some caching that isn't doing what it should. Indeed, if I go into app/models/package_branch.rb and comment out lines 173 and 175 to disable caching, everything works as it should (albeit slower).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants