Possible bug in url_for()

url_for seems to have a bug when dealing with modules.

If in the module a/controller b directory

If I make the following call to url_for to link to another action in the
same controller passing the parameters through, an incorrect URL is
generated.

url_for(:action => “test”, :params => params)

The url generated by this code is:
/a/a/b/test?..

The module name a got repeated. To get this to behave right, you need to
manually add :controller => nil to list of options to url_for.

Andrew S. <[email protected]…> writes:

url_for(:action => “test”, :params => params)

The url generated by this code is:
/a/a/b/test?..

The module name a got repeated. To get this to behave right, you need to
manually add :controller => nil to list of options to url_for.

I seem to remember there being a reason for that, to do with how
controllers are
rooted to something or other (I forget). In any case, it definitely goes
against
principle of least surprise so I’d call it a bug too

Gareth

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs