Hello all, I have an app mounted under /test via lighttpd fastcgi as indicated on [1]. Here I use R(Foo, bar) in views to link to controller foo, this correctly creates a /test/foo/bar link. However, when I use R() in some controller, for example: headers[''Refresh''] = "60; url=#{R(Foo, bar)}" The generated link is /foo/bar, which obviously links to something non-existant. Can somebody affirm that R() in controllers do not work correctly? Regards, Paul -- Student @ Eindhoven | email: paul at luon.net University of Technology, The Netherlands | JID: paul at luon.net>>> Using the Power of Debian GNU/Linux <<< | GnuPG key ID: 0x50064181
Paul van Tilburg wrote:> Here I use R(Foo, bar) in views to link to controller foo, this correctly > creates a /test/foo/bar link. However, when I use R() in some controller, > for example: > > headers[''Refresh''] = "60; url=#{R(Foo, bar)}" > > The generated link is /foo/bar, which obviously links to something > non-existant. Can somebody affirm that R() in controllers do not > work correctly?I don''t think it''s working incorrectly -- just a little unintuitively. In short, R() only prepends the app root (i.e. ''/test'') to the generated URL when called from within a View -- not Controllers. This can be worked around by using the "slash method"[1]: self / R(Foo, Bar) #=> ''/test/foo/bar'' See the Camping docs for the R() helper method[2], and the "Using R in the View" section in particular, for a fuller explanation. -- Adam [1] http://camping.rubyforge.org/classes/Camping/Helpers.html#M000016 [2] http://camping.rubyforge.org/classes/Camping/Helpers.html#M000014
On Wed, Nov 29, 2006 at 10:00:52AM +0000, Adam Harper wrote:> Paul van Tilburg wrote: > > Here I use R(Foo, bar) in views to link to controller foo, this correctly > > creates a /test/foo/bar link. However, when I use R() in some controller, > > for example: > > > > headers[''Refresh''] = "60; url=#{R(Foo, bar)}" > > > > The generated link is /foo/bar, which obviously links to something > > non-existant. Can somebody affirm that R() in controllers do not > > work correctly? > > I don''t think it''s working incorrectly -- just a little unintuitively. > In short, R() only prepends the app root (i.e. ''/test'') to the > generated URL when called from within a View -- not Controllers.Yes, I see what you mean. Thanks for pointing that out. Indeed, you assume it is going to behave the same. Kind regards, Paul -- Student @ Eindhoven | email: paul at luon.net University of Technology, The Netherlands | JID: paul at luon.net>>> Using the Power of Debian GNU/Linux <<< | GnuPG key ID: 0x50064181