studentss
studentss

Reputation: 57

image not displayed in html5 table on cloud9 for ruby on rails

Here is my code where I put in an img tag to show a picture. I saw from another answer I'm supposed to put the full path. Can someone show what that is when you use Cloud9?

<h1>CandyPages#home</h1>
<p>This is the home page for the
<img src="assets/images/slide-1.jpg" alt="Top-Selling Sweets"   
 width="600"  height="350">
candy app
</p>
<p>Find me in app/views/candy_pages/home.html.erb</p>

Upvotes: 0

Views: 716

Answers (1)

James
James

Reputation: 630

This problem probably has nothing to do with Cloud9, cloud9 is just the development kit you are using. Are you seeing a broken image icon in your browser?

9 times out of 10, the reason for a broken image in the browser is because the image url is not correct.

Have you tried using erb's image_tag helper? The rails asset pipeline is a wonderful thing once you start to understand it. Here is some instructions on using the image_tag() helper instead of HTML's img src

http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/image_tag

I would try substituting:

<img src="assets/images/slide-1.jpg" alt="Top-Selling Sweets"   
width="600"  height="350">

with instead:

 <%= image_tag("slide-1.jpg", size: "600") %>

Upvotes: 2

Related Questions