Ruby on rails 4 如何在rails 4中指定asset_主机?
我在config/environments/staging.rb中写道:我使用AmazonS3上传文件,使用Cloudfront服务静态资产Ruby on rails 4 如何在rails 4中指定asset_主机?,ruby-on-rails-4,amazon-s3,actionmailer,amazon-cloudfront,ruby-2.1,Ruby On Rails 4,Amazon S3,Actionmailer,Amazon Cloudfront,Ruby 2.1,我在config/environments/staging.rb中写道:我使用AmazonS3上传文件,使用Cloudfront服务静态资产 ActionController::Base.asset_host = Proc.new { |source| if source.include?('/assets') "d1xw0c7m8has5k.cloudfront.net" else "#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"
ActionController::Base.asset_host = Proc.new { |source|
if source.include?('/assets')
"d1xw0c7m8has5k.cloudfront.net"
else
"#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"
end
}
ActionMailer::Base.asset_host = Proc.new { |source|
if source.include?('/assets')
"d1xw0c7m8has5k.cloudfront.net"
else
"#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"
end
}
但在我的my mail send by rails应用程序中,我看到image_tagsrc
属性为空?
i、 e.没有显示图像。
此设置有什么问题我无法确定,请帮助。我通过将这些配置放在config/environments/staging.rb的块中来解决此问题
Demo::Application.configure do
config.action_controller.asset_host = Proc.new { |source|
if source.include?('/assets')
"d1xw0c7m8has5k.cloudfront.net"
else
"#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"
end
}
config.action_mailer.asset_host = Proc.new { |source|
if source.include?('/assets')
"http://d1xw0c7m8has5k.cloudfront.net"
else
"http://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"
end
}
end
并且有必要为协议提供action\u mailer asset\u host,即“HTTP”