[Nitro] Idiom to pass multiple parameters

James Britt james_b at neurogami.com
Sun Sep 4 14:12:33 EDT 2005


Aleksi Niemela wrote:
> I know this is the usual way to introduce an action:
> 
>  def categories
>    # do something useful with @category
>  end
>  action :categories, :route => /category\/(.*)/, 'category' => nil
> 
> But how should I pass on multiple parameters? Url format of
> 
>   /foo/84/bar/3902
> 
> doesn't look outright horrible but can stay quite pretty for few 
> parameters. It's surely more of a nuisance with dozens of parameters. 

I've used that sort of format in a few different cases, where I sort of 
treat the URL as a command line.

The way I would map this is:

action :categories, :route => /category	\/(.+)/, 'param_url' => String

Then your method code can take the @param_url string and parse it as it 
wishes.

In my case, I've been poking around with different ways to encode 
complex request params, so I wanted things that look like this:

www.exmple.com/find/foo/bar+baz/ick,blick,ploo[foz]


James

-- 

http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com  - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com  - Playing with Better Toys



More information about the Nitro-general mailing list