Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #6309 (closed defect: untested)

Opened 2 years ago

Last modified 2 years ago

Formatted routes are broken with caching (possibly problems elsewhere too)

Reported by: Si Assigned to: David
Priority: normal Milestone: 1.x
Component: ActionPack Version: edge
Severity: normal Keywords:
Cc:

Description

I'm using a formatted named route to create a URI:

formatted_test_url(:id => test.id, :format => :js)

Then I cache the action output:

caches_page :show

But the resulting cached file is 1.html say for test.id of 1, instead of 1.js

This is because resources.rb adds the less specific, non formatted routes before the formatted, resulting in this:

"Routes->GET /tests/:id/ {:controller=>\"tests\", :action=>\"show\"}GET /tests/:id.:format/ {:controller=>\"tests\", :action=>\"show\"}ANY /:controller/:action/:id/ {}"

If I monkey around with resources.rb & map the more specific formatted routes first, I get this:

"Routes->GET /tests/:id.:format/ {:controller=>\"tests\", :action=>\"show\"}GET /tests/:id/ {:controller=>\"tests\", :action=>\"show\"}ANY /:controller/:action/:id/ {}"

which adheres to the general specificity ordering of routes.rb (as per Changeset 5148), and a nice cached 1.js page that respects the format.

Change History

11/05/06 11:29:04 changed by Si

This seems to have been fixed in rev 5289

11/05/06 19:22:10 changed by bitsweat

  • status changed from new to closed.
  • resolution set to untested.