Hi, I have some images stored in the database and am attempting to build a img link to them. I would prefer to use a syntax that doesn''t restrict me to a hard coded path, something like this: <%= image_tag(url_for(:controller => ''member_pics'', :action => ''show'', :id => member_pic.id), :alt => member_pic.member.full_name, :size => "150x150") %> However rails appends a .png automatically to my path so that the functional path "/member_pics/show/4" becomes the disfunctional path "/member_pics/show/4.png". Is there a way to disable the magic in this case (rails 0.13.1)? I have worked around the issue for now by building up the img tag myself ... <img src="<%= url_for :controller => ''member_pics'', :action => ''show'', :id => member_pic.id %>" alt="<%= member_pic.member.full_name %>" height="150" width="150"> Thanks, Fraser
Yeah, an :add_suffix=>false or something would be nice. I may run into this problem myself, and would probably use .sub(/\..*$/,'''') to remove the suffix. csn --- Fraser Campbell <fraser-eicrhRFjby5dCsDujFhwbypxlwaOVQ5f@public.gmane.org> wrote:> Hi, > > I have some images stored in the database and am attempting to build a > img link to them. I would prefer to use a syntax that doesn''t restrict > me to a hard coded path, something like this: > > <%= image_tag(url_for(:controller => ''member_pics'', > :action => ''show'', > :id => member_pic.id), > :alt => member_pic.member.full_name, > :size => "150x150") %> > > However rails appends a .png automatically to my path so that the > functional path "/member_pics/show/4" becomes the disfunctional path > "/member_pics/show/4.png". > > Is there a way to disable the magic in this case (rails 0.13.1)? I have > worked around the issue for now by building up the img tag myself ... > > <img src="<%= url_for :controller => ''member_pics'', :action => > ''show'', :id => member_pic.id %>" alt="<%= member_pic.member.full_name > %>" height="150" width="150"> > > Thanks, > Fraser > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >__________________________________ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs
On 12/3/05, Fraser Campbell <fraser-eicrhRFjby5dCsDujFhwbypxlwaOVQ5f@public.gmane.org> wrote:> Hi, > > I have some images stored in the database and am attempting to build a > img link to them. I would prefer to use a syntax that doesn''t restrict > me to a hard coded path, something like this: > > <%= image_tag(url_for(:controller => ''member_pics'', > :action => ''show'', > :id => member_pic.id), > :alt => member_pic.member.full_name, > :size => "150x150") %> > > However rails appends a .png automatically to my path so that the > functional path "/member_pics/show/4" becomes the disfunctional path > "/member_pics/show/4.png". > > Is there a way to disable the magic in this case (rails 0.13.1)? I have > worked around the issue for now by building up the img tag myself ... > > <img src="<%= url_for :controller => ''member_pics'', :action => > ''show'', :id => member_pic.id %>" alt="<%= member_pic.member.full_name > %>" height="150" width="150">Dunno how to fix the issue, but I''d create a helper: class ApplicationHelper def show_image id # generate <img src tag> end end And then use that.
Joe Van Dyk wrote:> Dunno how to fix the issue, but I''d create a helper: > > class ApplicationHelper > def show_image id > # generate <img src tag> > end > endGood plan, I only have a few pages that will be displaying these images but it''s probably still worth a helper to keep things a little less wordy.