[Mongrel] --prefix, url_for and image_tag

Joey Geiger jgeiger at gmail.com
Fri Oct 26 09:22:03 EDT 2007


I had to modify image_tag and add in a "nostrip" attribute. If there's
a better way, please post it up.

  def image_tag(source, options = {})
    options.symbolize_keys!
    source = source+".png" unless source =~ /\.[gif|jpg|png]/
    if options.has_key?(:nostrip)
      options[:src] = image_path(source)
    else
      options[:src] = image_path(source).gsub(/\/myPrefix/,'')
    end
    options[:alt] ||= File.basename(options[:src],
'.*').split('.').first.capitalize
    if options[:size]
      options[:width], options[:height] = options[:size].split("x")
      options.delete :size
    end
    tag("img", options)
  end



On 10/25/07, Geoff Coffey <gwcoffey at gmail.com> wrote:
> First time here, so I hope this isn't a FAQ (although I did check
> *the* faq).
>
> I'm using mongrel_cluster with --prefix, and it is very slick. Thanks
> for that. But I had one problem. At one point in my little app, I
> have something like this:
>
>     image_tag(url_for(:action => 'picture', :id => 1), :size =>
> "160x200")
>
> In this scenario, the modified prefix behavior causes the prefix to
> be added twice. I get this output:
>
>     http://mysite/my-prefix/my-prefix/picture/1
>
> I may be doing this wrong. It does work properly without --prefix in
> the mix, and i can see how both these methods might add the prefix,
> causing this problem. Is this a bug? Known problem? Limitation of --
> prefix? Or just a confused poster?
>
> Thanks!
>
> Geoff
>
>
>> Geoff Coffey | 602.384.1804
> 9 Tips for FileMaker 9
> http://sixfriedrice.com/wp/category/filemaker-9-tips/
>
>
> _______________________________________________
> Mongrel-users mailing list
> Mongrel-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mongrel-users
>


More information about the Mongrel-users mailing list