Bugs / Issues: Browse | Submit New | Admin
setup production (debian server) with REE and passenger 1.1.2 1) <img src='#{@pic.public_filename('tn')}'/> This add an additional / at the end of the picture name, then the pic do not load. if a space is added <img src='#{@pic.public_filename('tn')}' /> this is working just fine. (both versions are working fine with mongrel) 2) more bothering: Using attachement_fu In the view: <div class="ci_thumb"> <% if item.product.pics[0]%> <%= image_tag(item.product.pics[0].public_filename("tn") ) %> test5: <%= item.product.pics[0].public_filename %> test6: <%= @product.pics[0].public_filename %> <%#debugger%> <%end%> </div> In the model: def full_filename(thumbnail = nil) file_system_path = (thumbnail ? thumbnail_class : self).attachment_options[:path_prefix] if self.thumbnail !=nil File.join(RAILS_ROOT, file_system_path, self.thumbnail, thumbnail_name_for(thumbnail)) else File.join(RAILS_ROOT, file_system_path, thumbnail_name_for(thumbnail)) end end def public_filename(thumbnail = nil) if self.thumbnail !=nil full_filename(thumbnail).gsub %r(^#{Regexp.escape(base_path+self.thumbnail)}), '' else full_filename(thumbnail).gsub %r(^#{Regexp.escape(base_path)}), '' end end test5 return the full system path test6 return the correct path (gsub remove correctly the base_path) When I get the "public_filename", if the object is a linked record, the "public_filename" return the full system path /home/www/site/image/image_name instead of simply /imeges/image_name I checked that full_filename is correct in both cases, bases_path correct too. this gives 2 possibilities: either - the gsub is not correctly executed - the public_filename do not return the last value everything is working well with mongrel. Best, Yves Lucas AWDb.com
Add A Comment:
Date: 2009-03-21 17:45 Sender: Yves Lucas I tried somthing esle dumb: I have the product as a joint table of the item, then item.product.pic[0] is my pic picture id and this should work, but isn't. I get the full system path! <%= image_tag(item.product.pics[0].public_filename("tn")) %> I pull the product record from the database, then I get the picture, this is working fine! (but bad junk code with un-necessary database access) <% p = Product.find(item.product[:id]) %> <%= image_tag(p.pics[0].public_filename("tn")) %> This is over my head.... If you need more info you can contact me: yves ät awdb.com
Date: 2009-03-21 13:07 Sender: Yves Lucas I tried somthing esle dumb: I have the product as a joint table of the item, then item.product.pic[0] is my pic picture id and this should work, but isn't. I get the full system path! <%= image_tag(item.product.pics[0].public_filename("tn")) %> I pull the product record from the database, then I get the picture, this is working fine! (but bad junk code with un-necessary database access) <% p = Product.find(item.product[:id]) %> <%= image_tag(p.pics[0].public_filename("tn")) %> This is over my head.... If you need more info you can contact me: yves ät awdb.com
Date: 2009-03-20 16:39 Sender: Yves Lucas I tried somthing esle dumb: I have the product as a joint table of the item, then item.product.pic[0] is my pic picture id and this should work, but isn't. I get the full system path! <%= image_tag(item.product.pics[0].public_filename("tn")) %> I pull the product record from the database, then I get the picture, this is working fine! (but bad junk code with un-necessary database access) <% p = Product.find(item.product[:id]) %> <%= image_tag(p.pics[0].public_filename("tn")) %> This is over my head.... If you need more info you can contact me: yves ät awdb.com