# Routing via regexp with map.resources?

**URL:** <https://www.ruby-forum.com/t/routing-via-regexp-with-map-resources/171623>\
**Category:** Rails\
**Created:** [July 6, 2009, 7:00pm UTC](https://www.ruby-forum.com/t/routing-via-regexp-with-map-resources/171623 "2009-07-06T19:00:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Larimer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f4b2a3/32.png) [@Mark\_Larimer](https://www.ruby-forum.com/u/Mark_Larimer)\
**Post date:** [July 6, 2009, 7:00pm UTC](https://www.ruby-forum.com/t/routing-via-regexp-with-map-resources/171623/1 "2009-07-06T19:00:35Z")

</div>

I have a requirement to support a query syntax on my resources like  
so:

[http://localhost:3000/people(last\_name=jones).xml](http://localhost:3000/people(last_name=jones).xml)

I can hook that up so that the people controller receives that action  
via map.connect like so:

map.connect ‘:people\_query\_regexp’,  
:controller =\> ‘people’,  
:index =\> ‘index’,  
:requirements =\> { :people\_query\_regexp =\> /people.\*/ }

But people is a RESTful resource, so I want to do the same thing using  
map.resources instead of map.connect. If I change the routing to:

map.resources ‘:parties\_query\_regexp’,  
:controller =\> ‘parties’,  
:requirements =\> { :parties\_query\_regexp =\> /  
parties.\*/ }

…then the server fails on startup like so:

lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action\_controller/routing/  
route\_set.rb:141:in `define_hash_access': (eval):3:in `define\_hash\_access’: compile error  
(SyntaxError) (eval):1: syntax error, unexpected ‘:’, expecting ‘\n’  
or ‘;’  
def hash\_for\_:people\_query\_regexp\_index\_pat…

It chokes on a syntax error because there’s a colon in the middle of  
the method name it’s trying to define.

So is there a way around this? What am I doing wrong? This is Rails  
2.2.2, btw.

Thanks.  
–mark
