spree::config and asset_url

199 views
Skip to first unread message

Steve Root

unread,
May 4, 2012, 12:10:17 PM5/4/12
to spree...@googlegroups.com
Can some of the experts here give me a steer on fixing this please.

The issue I'm trying to fix ( https://github.com/spree/spree_paypal_express/issues/52 ) - I know I can work around the problem easily but I'm masochistically trying to put something back into spree rather than just take ;-)

which is caused when a "Spree::Config.set(:logo..." uses a full url path to a remote image, eg
at the point where Spree_paypal_express calls from checkout_controller_decorator.rb 
:header_image            => asset_url(Spree::Config[:logo]),
If I have
Spree::Config.set(:logo => 'rails.png')
It works as expected (process continues to the paypal hosted pages).  

Reading some rails documentation suggested asset_url is used with asset_host. setting an asset host in my environment.rb
ActionController::Base.asset_host = "assets.example.com",
has no effect (rails.png works as before but acquires the correct asset host url, the full url version of http://s3...logo.png is unaltered in spree) so works or fails in exactly the same way.

So, any suggestions as to where I should start looking to solve this please?
Thanks,
Steve

Ryan Bigg

unread,
May 4, 2012, 2:23:22 PM5/4/12
to spree...@googlegroups.com
You could check to see if it is an absolute URI by using this code:

uri = URI.parse(Spree::Config[:logo])
uri.absolute?

Then if it is an absolute URL, don't both with the asset_url call. If it isn't, DO BOTHER with the asset_url call.

That should allow you to still use just image paths like rails.png and full URLs like what you're trying to do.
--
You received this message because you are subscribed to the Google Groups "Spree" group.
To view this discussion on the web visit https://groups.google.com/d/msg/spree-user/-/rHfbTFI-irQJ.
To post to this group, send email to spree...@googlegroups.com.
To unsubscribe from this group, send email to spree-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.

Steve Root

unread,
May 9, 2012, 7:25:13 AM5/9/12
to spree...@googlegroups.com
Thanks Ryan.  
I've now got a working patch that I just need to test in a couple of different ways then I'll submit a patch.
Reply all
Reply to author
Forward
0 new messages