Ruby on rails 产品中的rails映像路径问题,没有自定义域,没有指纹,路径错误

Ruby on rails 产品中的rails映像路径问题,没有自定义域,没有指纹,路径错误,ruby-on-rails,ruby-on-rails-3,asset-pipeline,Ruby On Rails,Ruby On Rails 3,Asset Pipeline,这是一个rails 3.2.13应用程序 我很困惑这里的问题是什么。非常感谢您的帮助。 我在这个位置有我的图像: app/assets/images/icons/apple-touch-icon-precomposed.png public/assets/icons/apple-touch-icon-precomposed-5796a048f16a314924adbb237adf88d6.png 这在layout.html.erb中: <link rel="apple-touch-ic

这是一个rails 3.2.13应用程序

我很困惑这里的问题是什么。非常感谢您的帮助。 我在这个位置有我的图像:

app/assets/images/icons/apple-touch-icon-precomposed.png
public/assets/icons/apple-touch-icon-precomposed-5796a048f16a314924adbb237adf88d6.png
这在layout.html.erb中:

<link rel="apple-touch-icon-precomposed" href="<%= image_path("icons/apple-touch-icon-precomposed.png") %>" />
这是我的
config/environments/production.rb

Aliencom::Application.configure do
  # Settings specified here will take precedence over those in config/application.rb

  # Code is not reloaded between requests
  config.cache_classes = true

  # Full error reports are disabled and caching is turned on
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true

  # Disable Rails's static asset server (Apache or nginx will already do this)
  config.serve_static_assets = false

  # Compress JavaScripts and CSS
  config.assets.compress = true

  # Don't fallback to assets pipeline if a precompiled asset is missed
  config.assets.compile = false

  # Generate digests for assets URLs
  config.assets.digest = true

  # Defaults to nil and saved in location specified by config.assets.prefix
  # config.assets.manifest = YOUR_PATH

  # Specifies the header that your server uses for sending files
  # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
  config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx

  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
  # config.force_ssl = true

  # See everything in the log (default is :info)
  config.log_level = :debug

  # Prepend all log lines with the following tags
  # config.log_tags = [ :subdomain, :uuid ]

  # Use a different logger for distributed setups
  # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)

  # Use a different cache store in production
  # config.cache_store = :mem_cache_store

  # Enable serving of images, stylesheets, and JavaScripts from an asset server
  config.action_controller.asset_host = 'http://asset.domain.com'

  # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)

  config.assets.precompile += ['head.js']
  config.assets.precompile += ['libs/respond.src.js']
  config.assets.precompile += ['libs/jquery-1.10.2.js']
  config.assets.precompile += ['libs/swfobject.js']
  config.assets.precompile += ['libs/greensock/TweenMax.min.js']
  config.assets.precompile += ['libs/greensock/plugins/ScrollToPlugin.min.js']

  # Add the fonts and swfs path
  config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
  config.assets.paths << Rails.root.join('app', 'assets', 'swfs')

  # Disable delivery errors, bad email addresses will be ignored
  # config.action_mailer.raise_delivery_errors = false

  # Enable threaded mode
  # config.threadsafe!

  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  # the I18n.default_locale when a translation can not be found)
  config.i18n.fallbacks = true

  # Send deprecation notices to registered listeners
  config.active_support.deprecation = :notify

  # Log the query plan for queries taking more than this (works
  # with SQLite, MySQL, and PostgreSQL)
  # config.active_record.auto_explain_threshold_in_seconds = 0.5



  Paperclip::Attachment.default_options.update({
       #:url => "i/:class/:attachment/:basename_:style_:hash.:extension",
       # :url => "/system/:class/:attachment/:id_partition/:style/:basename.:extension",
       #:url => "/system/v2/:class/:attachment/:id/:style_:created_at.:extension",
       :use_timestamp => false,
       :url => "//assets.staging.aliencom.net/system/v3/:class_:attachment/:id/:basename_:style.:extension",
       :path => ":rails_root/public/system/v3/:class_:attachment/:id/:basename_:style.:extension",
       :hash_secret => "P/IbDQ4t2qYNLCKyVREvRhyRPWYHn3CW3fAsIGYsnAa3OfWBJeIE91gW9ZyLWZPBW+TlqI278yLtGA7BIZB+DTR9Bp9J0usbFMn7mCh1aLAn2WKzZYrrJZ0QcFL5TEkYhDISKymd34bwS0x2zOhdzeKaSkQn9iXidvQ++Pt0YBg="
   })

end

根据我在生产中的经验,从公共目录加载的文件没有经过编译。 尝试将图像与文件名完整的相应文件夹一起放入公共目录


因此,对于
/icons/apple-touch-icon-precomposed.png
将其放入
/public/assets/icons/apple-touch-icon-precomposed.png
尝试放入未编译的图像。

您是否正在运行
RAILS\u ENV=production-rake-assets:precompile
?它现在指向产品中的链接是什么?右键单击并查看url。是的,需要在prod模式下预编译资产才能找到它们。不过,根据您发布的链接,我认为它们是正确的。@Slicedpan我发布了capistrano输出,我认为这是正确的行。@Isafie生产路径输出包含在上面。@LessQuesar尝试转换erb/haml(无论您使用什么)是的,这确实有效。主要令人沮丧的是,我不知道如何为指纹/自定义域等正确使用图像路径。CSS和JS链接良好。这是一个常见问题。我有一个应用程序与另一个应用程序使用相同的代码,其中一个将使用编译后的图像,而另一个则对原始图像大喊大叫。我还没有发现原因。有点像魔术,我让它起作用了。我黑了一堆像这里描述的设置:还有更多,不确定是什么造成了不同。但我想我要结束这一次了。
public/assets/icons/apple-touch-icon-precomposed-5796a048f16a314924adbb237adf88d6.png
Aliencom::Application.configure do
  # Settings specified here will take precedence over those in config/application.rb

  # Code is not reloaded between requests
  config.cache_classes = true

  # Full error reports are disabled and caching is turned on
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true

  # Disable Rails's static asset server (Apache or nginx will already do this)
  config.serve_static_assets = false

  # Compress JavaScripts and CSS
  config.assets.compress = true

  # Don't fallback to assets pipeline if a precompiled asset is missed
  config.assets.compile = false

  # Generate digests for assets URLs
  config.assets.digest = true

  # Defaults to nil and saved in location specified by config.assets.prefix
  # config.assets.manifest = YOUR_PATH

  # Specifies the header that your server uses for sending files
  # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
  config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx

  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
  # config.force_ssl = true

  # See everything in the log (default is :info)
  config.log_level = :debug

  # Prepend all log lines with the following tags
  # config.log_tags = [ :subdomain, :uuid ]

  # Use a different logger for distributed setups
  # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)

  # Use a different cache store in production
  # config.cache_store = :mem_cache_store

  # Enable serving of images, stylesheets, and JavaScripts from an asset server
  config.action_controller.asset_host = 'http://asset.domain.com'

  # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)

  config.assets.precompile += ['head.js']
  config.assets.precompile += ['libs/respond.src.js']
  config.assets.precompile += ['libs/jquery-1.10.2.js']
  config.assets.precompile += ['libs/swfobject.js']
  config.assets.precompile += ['libs/greensock/TweenMax.min.js']
  config.assets.precompile += ['libs/greensock/plugins/ScrollToPlugin.min.js']

  # Add the fonts and swfs path
  config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
  config.assets.paths << Rails.root.join('app', 'assets', 'swfs')

  # Disable delivery errors, bad email addresses will be ignored
  # config.action_mailer.raise_delivery_errors = false

  # Enable threaded mode
  # config.threadsafe!

  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  # the I18n.default_locale when a translation can not be found)
  config.i18n.fallbacks = true

  # Send deprecation notices to registered listeners
  config.active_support.deprecation = :notify

  # Log the query plan for queries taking more than this (works
  # with SQLite, MySQL, and PostgreSQL)
  # config.active_record.auto_explain_threshold_in_seconds = 0.5



  Paperclip::Attachment.default_options.update({
       #:url => "i/:class/:attachment/:basename_:style_:hash.:extension",
       # :url => "/system/:class/:attachment/:id_partition/:style/:basename.:extension",
       #:url => "/system/v2/:class/:attachment/:id/:style_:created_at.:extension",
       :use_timestamp => false,
       :url => "//assets.staging.aliencom.net/system/v3/:class_:attachment/:id/:basename_:style.:extension",
       :path => ":rails_root/public/system/v3/:class_:attachment/:id/:basename_:style.:extension",
       :hash_secret => "P/IbDQ4t2qYNLCKyVREvRhyRPWYHn3CW3fAsIGYsnAa3OfWBJeIE91gW9ZyLWZPBW+TlqI278yLtGA7BIZB+DTR9Bp9J0usbFMn7mCh1aLAn2WKzZYrrJZ0QcFL5TEkYhDISKymd34bwS0x2zOhdzeKaSkQn9iXidvQ++Pt0YBg="
   })

end
...
INFO [231ef199] Running ~/.rbenv/bin/rbenv exec bundle exec rake assets:precompile on 97.107.134.133
DEBUG [231ef199] Command: cd /var/www/ac_staging/releases/20140226162225 && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=1.9.3-p448 RAILS_ENV=staging ~/.rbenv/bin/rbenv exec bundle exec rake assets:precompile )
DEBUG [231ef199]    /home/deploy/.rbenv/versions/1.9.3-p448/bin/ruby /var/www/ac_staging/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
INFO [231ef199] Finished in 95.166 seconds with exit status 0 (successful).
...