Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Joseph Mokenela
3,101 PointsUnable to access a static image
I have an image inside the assets/images folder of my ruby on rails application, But when I try to access that file (image) from my html.erb page, i get the 404 error.
I have tried src="image.gif">, src="/image.gif">, src="/images/image.gif">, src="assets/images/image.gif"> but none of them seem to work. What could I be doing wrong?
Kind Regards, Joseph
2 Answers
Adam Waxman
8,779 PointsCheckout the rails 'image_tag' helper function: http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-image_tag
image_tag("icon") is equivalent to # => <img alt="Icon" src="/assets/icon" />
Joseph Mokenela
3,101 PointsGot it! Thank you very much Adam, much appreciated.