|
Re: R() in controllers: msg#00037lang.ruby.camping.general
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
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | [ANN] Camping_generator, Mark Fredrickson |
|---|---|
| Next by Date: | Re: R() in controllers, Paul van Tilburg |
| Previous by Thread: | R() in controllers, Paul van Tilburg |
| Next by Thread: | Re: R() in controllers, Paul van Tilburg |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |