Forum: Ruby on Rails UrlRewriter problem in components

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.
0cb6e600ba4f94b3254e4b2195c6b133?d=identicon&s=25 Dave (Guest)
on 2006-02-24 16:10
Hi!

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
that.
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  %>
    </div>

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
http://dev.rubyonrails.org/browser/trunk/actionpac...

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' }

returns

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

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
link
    :url => { :params => params.merge(:key => 'value')

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

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