In my app, i''m storing the name of images in the database, and keeping the images in the /images folder. The index.html.erb for my view uses an image tag: <td><div class="icon"/><img src=<%=h reagent.icon %>/></div></td> which shows up correctly. attempting to show the same icon in the show.html.erb doesn''t show the image. adding a border to it shows a line about the size of a ''pipe command'' and then the name. <p> <b>Icon:</b> <img src=<%= @reagent.icon %> border=1/> <%=h @reagent.icon %> </p> i''ve been trying different formats for the last 3 hours with no success. is there a difference in the references for the two files? or is the icon just being squashed somehow? I''m using firefox2 on ubuntu 7.10 if that helps. -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
You can use image_tag(h.reagent.icon) and that''ll work instead of <img src=<%= h.reagent.icon %> /> On Sun, Mar 16, 2008 at 12:03 PM, Big Rog <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > In my app, i''m storing the name of images in the database, and keeping > the images in the /images folder. The index.html.erb for my view uses > an image tag: > > <td><div class="icon"/><img src=<%=h reagent.icon %>/></div></td> > > which shows up correctly. attempting to show the same icon in the > show.html.erb doesn''t show the image. adding a border to it shows a > line about the size of a ''pipe command'' and then the name. > > <p> > <b>Icon:</b> > <img src=<%= @reagent.icon %> border=1/> > <%=h @reagent.icon %> > </p> > > i''ve been trying different formats for the last 3 hours with no success. > is there a difference in the references for the two files? or is the > icon just being squashed somehow? I''m using firefox2 on ubuntu 7.10 if > that helps. > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Ryan Bigg wrote:> You can use image_tag(h.reagent.icon) and that''ll work instead of <img > src=<%= h.reagent.icon %> /> >I''ve only just started using Rails this week, so I''m pretty well lost, as the tutorials i''ve followed just say "click this then this and it''s done" instead of delving into why things are done. I''ve tried several variations of inserting your suggestion into the file, but with no success. The API listing on railsbrain.com only shows it used for absolute references, not variable references, so i''m stumped. did you mean <p> <b>Icon</p> <%= image_tag(h.reagent.icon) %> </p> or <p> <b>Icon</p> image_tag(h.reagent.icon) </p> The first one causes an error (wrong number of arguments (0 for 1)) and the second one only writes the text of that line to the page. All of the other references to reagent on the show.html.erb code use <%=h @reagent.<item> =%> and successfully call their data. -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Use the first one but remove the dot after the h h.reagent.icon -> h reagent.icon -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
iso .. wrote:> Use the first one but remove the dot after the h > > h.reagent.icon -> h reagent.icon<%= image_tag(h reagent.icon) %> results in a ''Broken pipe'' error... I''m using Ruby 1.8.6 with Rails 2.0.2 in NetBeans 6.0.1 as well. Is there some other way I can troubleshoot or debug this? -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Ok, i had a burst of inspiration whilst on the ''throne'' =P I looked at the page source from the rendered version and saw that the img tag didn''t include the /images/ prefix that i used in the index.html.erb file. The working code is: <p> <b>Icon:</b> <img src="/images/<%=h @reagent.icon %>" border=1 /> <%=h @reagent.icon %> </p> -- 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?hl=en -~----------~----~----~----~------~----~------~--~---