2
更新:我剛剛發現只有當我推到生產時,我的資產纔會出現在分期中。Heroku分段網站上未顯示新圖像資產
每當我添加新的圖像資源,預編譯它們,並部署到分段,他們不會出現。然而,一切都在本地和生產上工作。這是我的代碼和我的過程,每當添加新的圖像資產。任何幫助,將不勝感激。我對此很新,並且到處尋找答案。
staging.rb
Rails.application.configure do
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.action_mailer.default_url_options = { :host => 'http://site_name.herokuapp.com' }
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.assets.js_compressor = :uglifier
config.assets.compile = false
config.assets.digest = true
config.log_level = :debug
config.action_controller.asset_host = Proc.new { |source|
if source =~ /\b(.png|.jpg|.gif|.svg)\b/i
"http://key.cloudfront.net"
end
}
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
config.active_record.dump_schema_after_migration = false
end
我如何預編譯我的資產分期
RAILS_ENV=staging bundle exec rake assets:precompile
我如何預編譯我的資產進行生產
RAILS_ENV=staging bundle exec rake assets:precompile
application.rb中
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module InfoSite
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
config.serve_static_files = true
config.assets.compile = true
config.assets.configure do |env|
if Rails.env.development? || Rails.env.test?
env.cache = ActiveSupport::Cache.lookup_store(:memory_store)
end
end
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*. {rb,yml}').to_s]
# config.i18n.default_locale = :de
# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
end
end
我的用於添加圖片資源過程:
- 將圖像中的應用程序/資產/圖像
- 使用它在佈局(使用資產pipline:= image_tag'image.png')
- 本地檢查(一切正常)
- 使用
RAILS_ENV=staging bundle exec rake assets:precompile
- 使用
RAILS_ENV=production bundle exec rake assets:precompile
- 檢查github上,所有資產被更新,我可以看到,他們已經預編譯
- 混帳推分期主
現在,如果我認爲分期,資產回我一個空的圖像框,顯示圖像的名稱。
在我的過程中是否有某些我想念的東西?我應該採取不同的方法嗎?
我嘗試了這兩種方法,但我的資產仍未加載。我甚至嘗試刪除我的公共/資產文件夾並再次預編譯。我注意到我的新資產正在預編譯但未提供。這是否與你提供的方法有關?我欣賞幫助 – szier
你有沒有嘗試過我描述過的東西? –
是的,我嘗試了你描述的兩種方法。你是否需要其他可能對我有所幫助的信息? – szier