Dynamically modifying a url

I am prototyping a video centric application.

A page consists of:

  • a player
  • a list of available clips
  • a “forward to a friend” link

The forward to a friend link will present the user with a form to send a
email with a link to the clip --currently being played–. The player
has a javascript api that provides the ID of the currently playing clip.

Is there a common method of rendering a rails URL that takes into
account query parameter values that are dynamically generated on the
client side? I am currently:

  • using url_for to generate the base url
  • and then using link_to_function to call a client side function that
    takes the base url as an argument. The client side function then
    appends the current clip id as a query param and then sets the
    location.href to the new url.

I am relatively new to the framework, however it appears as if rails is
going to great lengths to shield the developer from knowing how to
encode or decode URLs. What I am doing is a violation of that
encapsulation and is pretty brittle.

Is there a view helper that already does this? Any better ideas?