Hi, I''m new to Rails, sorry if I''m repeating the question, but I couldn''t find a solution for my problem so far :( I''m using Apache2 as the web server of my Rails application. I keep my images in public/images and tried inserting images to the page like this; <%= image_tag "rails.png" %> But the image is not displayed on the browser. Can anyone pleeeeese point out the problem? I could do this using WEBrick though. -Umesha -- Posted via http://www.ruby-forum.com/.
Umesha wrote:> Hi, > I''m new to Rails, sorry if I''m repeating the question, but I couldn''t > find a solution for my problem so far :( > > I''m using Apache2 as the web server of my Rails application. I keep my > images in public/images and tried inserting images to the page like"public" is your webroot... that''s where apache starts looking for stuff to serve. "images" is a subdirectory of "public".> > <%= image_tag "rails.png" %>This is going to make an image tag with src="rails.png"... which, since you didn''t specify a path, means apache is going to look in your webroot... or the "public" directory. In other words, try "/images/rails.png". b> > But the image is not displayed on the browser. Can anyone pleeeeese > point out the problem? > > I could do this using WEBrick though. > > -Umesha >
Thanks a lot Ben, but still it doesn''t work. When I view the page source of the browser, it correctly shows as, <img alt="Rails" src="/images/rails.png" /> but still the image is not visible on any of the browsers. Ben Munat wrote:> Umesha wrote: >> Hi, >> I''m new to Rails, sorry if I''m repeating the question, but I couldn''t >> find a solution for my problem so far :( >> >> I''m using Apache2 as the web server of my Rails application. I keep my >> images in public/images and tried inserting images to the page like > > "public" is your webroot... that''s where apache starts looking for stuff > to serve. > "images" is a subdirectory of "public". > >> >> <%= image_tag "rails.png" %> > > This is going to make an image tag with src="rails.png"... which, since > you didn''t specify > a path, means apache is going to look in your webroot... or the "public" > directory. > > In other words, try "/images/rails.png". > > b-- Posted via http://www.ruby-forum.com/.
Try to right click on the missing image, choose properties (if your using firefox) and see what path is beeing used. You should be able to figure out why it is not displayed. On 3/6/06, Umesha Perera <uperera@virtusa.com> wrote:> > Thanks a lot Ben, but still it doesn''t work. When I view the page source > of the browser, it correctly shows as, > <img alt="Rails" src="/images/rails.png" /> > but still the image is not visible on any of the browsers. > > Ben Munat wrote: > > Umesha wrote: > >> Hi, > >> I''m new to Rails, sorry if I''m repeating the question, but I couldn''t > >> find a solution for my problem so far :( > >> > >> I''m using Apache2 as the web server of my Rails application. I keep my > >> images in public/images and tried inserting images to the page like > > > > "public" is your webroot... that''s where apache starts looking for stuff > > to serve. > > "images" is a subdirectory of "public". > > > >> > >> <%= image_tag "rails.png" %> > > > > This is going to make an image tag with src="rails.png"... which, since > > you didn''t specify > > a path, means apache is going to look in your webroot... or the "public" > > directory. > > > > In other words, try "/images/rails.png". > > > > b > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060306/79cb8948/attachment.html
Well you''ve got me stumped then... you''re sure it''s in the same app directory? b Umesha Perera wrote:> Thanks a lot Ben, but still it doesn''t work. When I view the page source > of the browser, it correctly shows as, > <img alt="Rails" src="/images/rails.png" /> > but still the image is not visible on any of the browsers. > > Ben Munat wrote: > >>Umesha wrote: >> >>>Hi, >>>I''m new to Rails, sorry if I''m repeating the question, but I couldn''t >>>find a solution for my problem so far :( >>> >>>I''m using Apache2 as the web server of my Rails application. I keep my >>>images in public/images and tried inserting images to the page like >> >>"public" is your webroot... that''s where apache starts looking for stuff >>to serve. >>"images" is a subdirectory of "public". >> >> >>><%= image_tag "rails.png" %> >> >>This is going to make an image tag with src="rails.png"... which, since >>you didn''t specify >>a path, means apache is going to look in your webroot... or the "public" >>directory. >> >>In other words, try "/images/rails.png". >> >>b > > >
Are you on a *nix platform? Is the file named "rails.png" exactly? or is it "Rails.png"? CaSe matters in *nix. ~ Ben On 3/5/06, Umesha <uperera@virtusa.com> wrote:> > Hi, > I''m new to Rails, sorry if I''m repeating the question, but I couldn''t > find a solution for my problem so far :( > > I''m using Apache2 as the web server of my Rails application. I keep my > images in public/images and tried inserting images to the page like > this; > > <%= image_tag "rails.png" %> > > But the image is not displayed on the browser. Can anyone pleeeeese > point out the problem? > > I could do this using WEBrick though. > > -Umesha > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Ben Reubenstein http://www.benr75.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060306/86c05f32/attachment.html
Ben Munat wrote:> Well you''ve got me stumped then... you''re sure it''s in the same app > directory? > > bYes, the image (rails.png) is placed in ''C:\Program Files\Apache Group\Apache2\htdocs\apache_rails\public\images\'' where my application folder is named as ''apache_rails''. And I''ve specified the Document root of Apache as ''DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/apache_rails/public"'' in httpd.conf file For the simplicity I have only following 2 lines in the relavent view file. <h1>Displaying an image</h1> <%= image_tag "/images/rails.png" %> But once it is viewed from a browser, only the heading is displayed with the word ''Rails'' under that and it''s page source is, <h1>Displaying an image</h1> <img alt="Rails" src="/images/rails.png" /> But once I do the same thing in a application using WEBrick server with the same view file and image placed in it''s ''public\images'', the image is visible. Also it''s page source is same as above. I really cannot find what''s the problem. :( -umesha -- Posted via http://www.ruby-forum.com/.
What URL are you using to access the app in Apache? On 3/7/06, Umesha Perera <uperera@virtusa.com> wrote:> > Ben Munat wrote: > > Well you''ve got me stumped then... you''re sure it''s in the same app > > directory? > > > > b > > Yes, the image (rails.png) is placed in > ''C:\Program Files\Apache > Group\Apache2\htdocs\apache_rails\public\images\'' where my application > folder is named as ''apache_rails''. > > And I''ve specified the Document root of Apache as > ''DocumentRoot "C:/Program Files/Apache > Group/Apache2/htdocs/apache_rails/public"'' in httpd.conf file > > For the simplicity I have only following 2 lines in the relavent view > file. > <h1>Displaying an image</h1> > <%= image_tag "/images/rails.png" %> > > But once it is viewed from a browser, only the heading is displayed with > the word ''Rails'' under that and it''s page source is, > <h1>Displaying an image</h1> > <img alt="Rails" src="/images/rails.png" /> > > But once I do the same thing in a application using WEBrick server with > the same view file and image placed in it''s ''public\images'', the image > is visible. Also it''s page source is same as above. > > I really cannot find what''s the problem. :( > > -umesha > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060307/7bb14488/attachment.html
Joshua Wehner wrote:> What URL are you using to access the app in Apache?I use ''http://localhost/friend/test_pic'' to access that page. I''ve defined the method ''test_pic'' in ''FriendController'' as below: class FriendController < ApplicationController def test_pic end ... end And the ''test_pic.rhtml'' has only these 2 lines: <h1>Displaying an image</h1> <%= image_tag "/images/rails.png" %> I still can''t figure out why the image is not displayed on the browser. Thanks, Umesha -- Posted via http://www.ruby-forum.com/.
On 3/13/06, Umesha Perera <uperera@virtusa.com> wrote:> > I use ''http://localhost/friend/test_pic'' to access that page. > [...] > And the ''test_pic.rhtml'' has only these 2 lines: > <h1>Displaying an image</h1> > <%= image_tag "/images/rails.png" %> > > I still can''t figure out why the image is not displayed on the browser. >Is the image at "http://localhost/friend/images/rails.png", or " http://localhost/images/rails.png" ? I''m guessing you want the former, but the code you''re using is generating the latter. -- Joshua -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060313/4235d336/attachment.html