0

As far as I can tell url helpers in Ruby on Rails only generate site root relative paths.

So if I want to go from http://exemple.com/categories/1 to http://exemple.com/questions/12 the link will be /questions/12 (site root relative path).

Are there any helpers/gems that would generate a document relative path (../questions/12) ?

4

1 回答 1

0

不确定是否理解问题。

假设您有以下两条路线:

resources :categories
resources :questions

您可以使用以下方法从一个跳转到另一个:

category_path(id)
question_path(id)

使用后缀path只会返回您的域的相对路径。而 usingurl将返回完整的 URL。

category_path(1) #=> /categories/1
category_url(1)  #=> http://exemple.com/categories/1
于 2013-09-04T10:33:54.123 回答