Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the image URL without the HTML in Rails

In Rails is there a way to get the URL to the image (going through the assets_host) and just return the URL of the image? I want to use assets_host data in my Javascript, but I just need to insert the URL into the JS, not the whole image_tag.

Thank you in advance!

like image 885
tesserakt Avatar asked May 20 '10 16:05

tesserakt


People also ask

How do I insert an image in HTML without URL?

Begin with the img tag. Find the point in your HTML body where you'd like to insert an image. Write the tag <img> here. This is an empty tag, meaning it stands alone, with no closing tag. Everything you need to display your image will go inside the two angle brackets.

What is the best way to get the current request URL in Rails?

You should use request. original_url to get the current URL.


1 Answers

image_path will return (you guessed it) the path to the image. It's the same method used in image_tag.

like image 59
Jordan Running Avatar answered Oct 06 '22 15:10

Jordan Running