Trip
Trip

Reputation: 27114

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 card_cutout.jpg in my public/images/ folder.

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

img = "http://www.website.com/images/card_cutout.jpg

Thanks in advance!

Upvotes: 0

Views: 566

Answers (2)

TVito Oz
TVito Oz

Reputation: 11

img = "#{Rails.root}/public/images/card_cutout.jpg"

Upvotes: 1

John Topley
John Topley

Reputation: 115292

Try this:

img = "#{Rails.root/public/images/card_cutout.jpg}"

Upvotes: 1

Related Questions