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) ?

Dorian
  • 2,571
  • 23
  • 33
  • did you try to put you documents in rails `public` folder and then access it like railsapp --> public--->folder1---->folder2---->my.html now access it http://localhost/folder1/folder2/my.html ...hope i am able to understand – Rajarshi Das Sep 04 '13 at 11:23

1 Answers1

0

Not sure to understand the question.

Assuming you have the two following routes:

resources :categories
resources :questions

You can jump from one to the other using:

category_path(id)
question_path(id)

Using the suffix path will only return the relative path for your domain. Whereas using url will return the full URL.

category_path(1) #=> /categories/1
category_url(1)  #=> http://exemple.com/categories/1
Pierre-Louis Gottfrois
  • 17,561
  • 8
  • 47
  • 71
  • Hi Pierre-Louis, I'm well aware of this behaviour. the category_path returns a site root relative path. I'm looking for a way to generate document relative paths. – Dorian Sep 04 '13 at 10:38
  • I've added a link in the question that explains the difference between document relative paths and site root relative paths. – Dorian Sep 04 '13 at 10:46
  • Ok I get it, the only way I see to perform such thing would be to add manually the `../` :( Let's wait if someone comes with a clever thing. – Pierre-Louis Gottfrois Sep 04 '13 at 11:47
  • @Pierre-LouisGottfrois did he asking about documents in rails public folder and then access it like railsapp --> public--->folder1---->folder2---->my.html now access it http://localhost:3000/folder1/folder2/my.html ...hope i am able to understand – Rajarshi Das Sep 04 '13 at 12:06
  • @Rajarshi Das This is not the question – Pierre-Louis Gottfrois Sep 04 '13 at 12:49
  • ooh got it....... but in rails route there is no such option you have to do it manually `match "../", ""` – Rajarshi Das Sep 04 '13 at 12:56