# Asset\_host and ssl pages problem

**URL:** <https://www.ruby-forum.com/t/asset-host-and-ssl-pages-problem/140379>\
**Category:** Rails\
**Created:** [June 13, 2008, 12:02pm UTC](https://www.ruby-forum.com/t/asset-host-and-ssl-pages-problem/140379 "2008-06-13T12:02:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![slonghurst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ac91a4/32.png) [@slonghurst](https://www.ruby-forum.com/u/slonghurst)\
**Post date:** [June 13, 2008, 12:02pm UTC](https://www.ruby-forum.com/t/asset-host-and-ssl-pages-problem/140379/1 "2008-06-13T12:02:14Z")

</div>

I am configuring assets hosts for our site but am running into problems  
when navigating to an https page. Basically the server is trying to pull  
the assests out on https:// rather than http:/ but i do not have https  
configured on the assets server. I have dug around a bit and found this  
bit of code which should when a page is https:// serve the assests from  
the app server and when it is not https serve the assets from the assets  
server.

ActionController::Base.asset\_host = Proc.new { |source, request|  
if request.ssl?  
“#{request.protocol}#{request.host\_with\_port}” # Disable asset  
hosting.  
else  
“#{request.protocol}[assets1.example.com](http://assets1.example.com)” # Use asset host.  
end  
}

but i always get this error when navigating to any page

Showing layouts/admin.html.erb where line #8 raised:  
You have a nil object when you didn’t expect it!  
The error occurred while evaluating nil.ssl?

Extracted source (around line #8):  
5:   
6:   
7:   
8: \<%= stylesheet\_link\_tag ‘shared’, ‘legacy\_admin’, ‘admin’, :media =\>  
“all” %\>  
9: \<%= javascript\_include\_tag :defaults %\>  
10: \<%= javascript\_include\_tag ‘clocks.js’ %\>  
11:

i have also tried this  
config.action\_controller.asset\_host = Proc.new do |source, request|  
request.ssl? || source = /javascripts/ ?  
“#{request.protocol}#{request.host\_with\_port}” :  
“[http://assets1.example.com](http://assets1.example.com)”  
end

but i get the same problem.

Any body else seen this problem? I am using rails 2.0.2 with mod\_rails  
1.0.5 and apache 2.2.6

---

<div class="post-metadata">

**Author:** ![slonghurst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ac91a4/32.png) [@slonghurst](https://www.ruby-forum.com/u/slonghurst)\
**Post date:** [June 13, 2008, 12:27pm UTC](https://www.ruby-forum.com/t/asset-host-and-ssl-pages-problem/140379/2 "2008-06-13T12:27:21Z")

</div>

turns out i needed rails 2.1.0 and actionpack 2.1.0 as there was a patch  
needed to asset\_tag\_helper.rb that i did not have.
