[Nitro] Idiom to pass multiple parameters

Aleksi Niemela Aleksi.Niemela at cs.helsinki.fi
Sun Sep 4 11:57:04 EDT 2005

I know this is the usual way to introduce an action:

  def categories
    # do something useful with @category
  action :categories, :route => /category\/(.*)/, 'category' => nil

But how should I pass on multiple parameters? Url format of


doesn't look outright horrible but can stay quite pretty for few 
parameters. It's surely more of a nuisance with dozens of parameters. 
Therefore I thought to go with


Is this the "right way" to do it? If this is the path, is the following 
the way to get the parameters to use them?

   uri = UriUtils.update_query_string("categories/#{@foo}", 
   <a href="#{uri}">bar</a>

  def categories
    params = UriUtils.query_string_to_hash(request.query_string)
    @bar = params["bar"]
    # use foo and bar in a useful way
  action :categories, :route => /category\/(.*)/, 'category' => nil

I find this way quite a bit clumsy. But if that's the way to work around 
I guess I'm forced to write up interception for an action method to set 
instance variables behind the scenes and gotta do something for the url 
building too.

I hope I've missed some elementary step but couldn't find any more 
complex actions in Spark. It was Pager mixin that showed me this way.

Or should I start using session or head my way to Wee like page storing?

   - Aleksi

More information about the Nitro-general mailing list