Resource routes with further options


#1

Hi you all,
I have a resource routed in routes.rb, such as
map.resources :queries

Every Query object has a string with words, and I want to operate on
each of these words ( each word will generate another object of type
Queryterm).

The thing is that I have the URL, let’s say /queries/123, and I want to
call the function (dunno if I’ll use the “edit” function or some other)
which operates on each of its words in this way:
/queries/123/[function]/:[position],
where “function” is the “edit” function or some other I may add with the
resource option :member, and :position is the position of the next word
I want to operate with (given the string with words of the query 123).

Question is, Can i have something like
map.resources :queries :member=> {:myfunction=>‘get’}
but, adding the fact that I am going to pass it a :position
parameter???

If not, I can use map.connect as usual (or put the :position integer in
the session), but I would like to know if there is any resource-styled
way to do it.

Lots of thanks.


#2

map.resources :queries, :member => {:myfunction => :get}

should do just fine, additional parameters don’t affect the routing

In my app I have:

map.resources :cdocs, :member => {:linkable => :get}

for one resource, and the linkable invocations take additional
parameters. Remember parameters come after the ? and don’t affect the
routing.


#3

Ok, I meant having a url such as
/myfunction/myparam,
not
/myfunction?param=myparam

just for the “?” mark, which is not “cool”, but in a second thought, I’m
afraid is more Restful than the first one.
Thanks!

Ar Chron wrote:

map.resources :queries, :member => {:myfunction => :get}

should do just fine, additional parameters don’t affect the routing

In my app I have:

map.resources :cdocs, :member => {:linkable => :get}

for one resource, and the linkable invocations take additional
parameters. Remember parameters come after the ? and don’t affect the
routing.