When coding a views/.rhtml file, where do the various directories fall in relation to my app. For example, if I have a file in public/images of "image1.jpg", I need to code a "<img src=......>" for it (I think, I won''t be shocked if someone says "in rails we do it this way). *IF* I''m coding the <img> tag, where is the file ... what directory path do I put in so I can find image1.jpg? Thanks in advance ---Michel -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Your web app generally maps to the Rails public folder. http://youapp.com/images/image1.jpg => /railsappname/public/images/image1.jpg You can make absolute references to your images using /images/image_name.gif from your views. This also applies to JavaScripts and stylesheets, which map to /javascripts and /stylesheets respectively. Of course you can use relative references, but I''ve found the safest bet to be absolute. -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Michael Satterwhite Sent: Tuesday, October 03, 2006 3:35 PM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] Where are directories When coding a views/.rhtml file, where do the various directories fall in relation to my app. For example, if I have a file in public/images of "image1.jpg", I need to code a "<img src=......>" for it (I think, I won''t be shocked if someone says "in rails we do it this way). *IF* I''m coding the <img> tag, where is the file ... what directory path do I put in so I can find image1.jpg? Thanks in advance ---Michel -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
> When coding a views/.rhtml file, where do the various directories fall > in relation to my app. For example, if I have a file in public/images of > "image1.jpg", I need to code a "<img src=......>" for it (I think, I > won''t be shocked if someone says "in rails we do it this way). *IF* I''m > coding the <img> tag, where is the file ... what directory path do I put > in so I can find image1.jpg?I would just do... <%= image_tag "image1.jpg" %> which will result in html similar to: <img src="/images/image1.jpg"> Which will look in RAILS_ROOT/public/images/image1.jpg for that file. -philip --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom wrote:> > <%= image_tag "image1.jpg" %> >I *KNEW* there''d be a rails way. I looked, but never found that. Thank you *VERY* much. ---Michael -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Michael Satterwhite wrote:> When coding a views/.rhtml file, where do the various directories fall > in relation to my app. For example, if I have a file in public/images of > "image1.jpg", I need to code a "<img src=......>" for it (I think, I > won''t be shocked if someone says "in rails we do it this way). *IF* I''m > coding the <img> tag, where is the file ... what directory path do I put > in so I can find image1.jpg?As far as your webserver is concerned, the root of your Rails app is the ''public'' directory. So if you have an image called image1.jpg in public/images, you can get to it using <img src="/images/image1.jpg" /> Incidentally, Rails has a built-in image tag helper that assumes that images are stored in the /images directory, so in this case you could use <%= image_tag("image1.jpg") %> Chris --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Chris Mear wrote:> > <img src="/images/image1.jpg" /> > > Incidentally, Rails has a built-in image tag helper that assumes that > images are stored in the /images directory, so in this case you could > use > > <%= image_tag("image1.jpg") %>Thanks, Chris, for both pieces of information. I was really looking for the rails helper (I''d guessed it existed but couldn''t find the reference), but also wanted to know where things were in case I needed them. Thanks again. ---Michael -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---