Forum: Ruby on Rails Resource routes with further options

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
28a4d1b683ec25e1d0312a2a90f63b6f?d=identicon&s=25 Damaris Fuentes (damaris)
on 2009-05-28 14:06
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.
D188e591eac11021329b8821a5f954c7?d=identicon&s=25 Ar Chron (railsdog)
on 2009-05-28 18:29
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.
28a4d1b683ec25e1d0312a2a90f63b6f?d=identicon&s=25 Damaris Fuentes (damaris)
on 2009-05-29 12:49
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.
This topic is locked and can not be replied to.