Trip Trip - 1 year ago 59
Ruby Question

How do you access your images folder from a controller?

I'm setting up Prawn right now and for one param it wants to know the img location.

In their case they wrote :

img = "#{Prawn::BASEDIR}/data/images/card_cutout.jpg"

But that points to a local gems folder. How can I make this from the controller point to
in my public/images/ folder.

I tried using an absolute link thinking it would work like a website but I was wrong :

img = "

Thanks in advance!

Answer Source

Try this:

img = "#{Rails.root/public/images/card_cutout.jpg}"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download