adamburmister / morning_glory

Manage deployments of Rails assets to the Amazon S3/Cloudfront CDN
MIT License
32 stars 12 forks source link

Rails 3 compatible? #6

Open professor opened 13 years ago

professor commented 13 years ago

Morning glory has been very helpful for me with my rails 2 application. I'm in the process of upgrading to rails 3, and I'm seeing this error message. I'm wondering if anyone has used this plugin with rails 3. Thanks!

ActionView::Template::Error (wrong number of arguments (2 for 1)):

vendor/plugins/morning_glory/lib/asset_tag_helper.rb:5:in `rewrite_asset_path'

professor commented 13 years ago

Solution? modify vendor/plugins/morning_glory/lib/asset_tag_helper.rb and replace existing method with this one:

def rewrite_asset_path(source, path = nil)
  if path && path.respond_to?(:call)
    return path.call(source)
  elsif path && path.is_a?(String)
    return path % [source]
  end

  asset_id = rails_asset_id(source)
  if asset_id.blank?
    source
  else
   # AB: As of June AWS Cloudfront supports HTTPS requests. This alternative code path should now be redundant.
    # # If the request isn't SSL, or if the request is SSL and the SSL host is set
    # if !request.ssl? || (request.ssl? && !AssetHostingWithMinimumSsl::asset_ssl_host.empty?)
    #   File.join('/', ENV['RAILS_ASSET_ID'], source)
    # else
    #   source + "?#{asset_id}"
    # end
    File.join('/', ENV['RAILS_ASSET_ID'], source)
  end
end