Hard to do: Creating routes that are permalinks with context info.

Simple permalinks, yes, like:


But I do *not* see how to create permalinks for large collections of
documents, like:


There's one big difference between the first and second example: In
the first, all the parameters would be attributes of the one
ActiveRecord object (the weather report from 10/3.)

But in the second examples, information from two sources is pulled
the user is focussing on France or Europe. I haven't figured out how
to generate these kinds of URLs yet. Anyone know how? Here's what I
have so far:

  map.weather_report '/:location/weather/report/:month/:day' ...

This nicely (1) sets an @location variable in the app so that the
entire interface is tailored for the user, and (2) instantiates
the :month/:day weather report, filtered by @location.

But my problem: I don't see how to use weather_report_path to
generate this URL. Given a report object, and @location, I've tried
variations of:

  weather_report_path(report, @location)

...without success.

Any ideas?

Hmm; it looks like one solution might be to use nested resources,
which would unfortunately require a longer url like this:


weather_report_url(:location => 'france', :month => 10, :day => 3)

Ummhmm, I can grab out the attributes of my Report object. And I guess
I can use that with link_to in a template:

  link_to('the report', weather_report_url(:location => @loc, :month
=> r.month, :day => r.day))

...I was hoping to get to something more like:

  link_to('the report', @loc, r)

You'll never get it quite that simple unless you write your own helper.

module MyHelper
   def weather_link_to(text, location, report, options={})
     link_to(text, weather_report_path(:location => location,
                                       :month => report.month,
                                       :day => report.day),

<%= weather_link_to('the report', @loc, r) %>


Rob Biedenharn http://agileconsultingllc.com