I've run across a bug with polymorphic_url, which I have reported here: http://rails.lighthouseapp.com/projects/8994/tickets/411-polymorphic_path-breaks-on-uncountable-resources
The gist of the problem is that passing an uncountable resource (such as an AR Model called Sheep) causes the method to throw an exception. The reason for this is because when you map an uncountable resource, you pass in a :singular option. Something like:
map.resources :sheep, :singular => :sheep_instance
That generates helpers called sheep_instance_url, edit_sheep_instance_url, etc.
This becomes an issue for polymorphic_url as it tries to call the named route helper, but has no good way of looking up the appropriate helper. polymorphic_url consults RecordIdentifier, which will try to get the singular name of the model. When this is done for an uncountable model the singular and plural name are the same and build_named_route_call will generate the wrong name for the helper (in the example, if you try polymorphic_url(@sheep) it will try to call sheep_url, when it should be calling sheep_instance_url). I don't see any good way on checking what the named_routes for an uncountable resource are...
Does anyone have any suggestions for fixing this bug?
Thanks, Andy