Forum: Ruby on Rails UrlRewriter problem in components

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Dave (Guest)
on 2006-02-24 17:10

It's not really a big deal, because the workaround is easy, but I don't
really know if it's a bug or a feature. Maybe someone can have a look on
I have a problem with creating links within components.

The scenario

My "index" action renders a "list" component by calling:
    <div id="list">
        <%= render_component :action => "list", :params => params  %>

Within this list, I have some navigation links. Those should only change
the content of the list, so I call
    link_to_remote "A link",
        :update => 'list', :url => { :params => { :key => 'value' } }
and receive a completely wrong result.

I did some debugging and found out, that the error happens in

UrlRewriter calls "Routing::Routes.generate(options.dup, @request)" and
passes @request, which is used for url-generation in next step. I've
made some debug output to point up the problem:

    puts params
    puts @request.path_parameters
    puts url_for :params => { :key => 'value' }


    {"action"=>"list", "id"=>nil, "controller"=>nil}
    {"action"=>"index", "controller"=>"items"}

but "url_for" should return "items/list?key=value" instead.

To get it working I use a workaround and always pass all params to the
    :url => { :params => params.merge(:key => 'value')

Is that a bug, or are there any ulterior motives behind that?

Thanks a lot
This topic is locked and can not be replied to.