views:

74

answers:

1

Does Rails have an equivalent of the Server.MapPath method from ASP.NET? I've tried looking for one, but couldn't find anything.

Edit: I need this to generate a PDF with some images stored on the server. I know the relative path (URL) of the images, but I need an absolute path on disk to load them. I use FPDF for this and even though it says it accepts an URL, it doesn't seem to be the case (or I couldn't make it work).

It checked that it works with a hardcoded physical disk path and now I need to make it flexible.

+4  A: 

Ruby has one: File.expand_path. You can also use Rails.root to get the current path to rails project, then compose the path from there.

File.join(Rails.root, "public", "404.html")
File.expand_path("public/404.html", Rails.root)
Simone Carletti
Thanks! That's what I was looking for.
rslite