<%= image_tag t.image %>


#1

On step 5, what is the significance of image_tag? The exercise passes without it if you were type only <%= t.image %>


#2

Hi Jay,

t.image is the image's URL. So,

<%= t.image %>

will show in Codecademy's virtual browser as something like:

https://s3.amazonaws.com/codecademy/codecademy-content/...

Whereas this:

<%= image_tag t.image %>

will show up as:

(or whatever image is hosted at t.image)

I hope this helps! :slight_smile:


#3

Thanks for the explanation Zeke. I'm still not fully grasping this.

To clarify, is the url for the image stored in the seeds.rb file from the db? I'm assuming yes. Also, is the image_tag equivalent to HTML's version of alt="image description" ?


#4

@jaydacoder That's fine, no worries :slight_smile:

is the url for the image stored in the seeds.rb file from the db?

Not quite. The image URL is stored in the database, seeds.rb simply fills the database with data when you run rake db:seed.

Also, is the image_tag equivalent to HTML's version of alt="image description" ?

No, <%= image_tag %> compiles to:

<img src="[t.image's value]" alt="optional parameter you can pass in to image_tag">

Feel free to ask any followup questions you may have :wink:


#5

Many Thanks Z! Appreciate your help. I think I understand now. To clarify...

1) image_tag is a helper so that RoR automatically knows to look in the assets folder for that image without having to type the entire path. ie) /assets/images/photo.jpg ???

2) If the image URL is stored in the db, is it stored in the file in the migrate folder? For example, 20150408005247_create_destinations.rb ?


#6

You're getting closer, but still don't quite understand it completely.

  1. image_tag: You can use it to get images stored in assets/, or you can use it to get an image at any location, for example one hosted on Imgur instead or something, image_tag isn't limited to images stored in the assets folder.
  2. The file in the migrate folder simply tells the database what data and types of data to store. You can't see the actual database anywhere, it's hidden.

You're starting to get it, let me know if you have any more questions :slight_smile: