到目前为止,这就是我所做的。
我在Capfile中加载了资源:js仍无效 http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets
我将咖啡轨从资产移到主要部分:仍然无法正常工作
gem'coffee-rails','〜> 3.2.1'
组:资产 宝石'sass-rails','〜> 3.2.3' 端
更新:生产环境
SolidAdmin :: Application.configure do #此处指定的设置将优先于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
Paperclip.options[:command_path] = "/usr/bin/"
# 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
# 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
# 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
end
其他所有内容都是默认/注释掉的
答案 0 :(得分:4)
固定!切换:
config.assets.compile = false
为:
config.assets.compile = true
现在可行。
答案 1 :(得分:4)
编辑:在聊天聊天之后,在页面中包含两次jquery是一个问题。
检查完你的页面后(liquid-radio.com),我看到了一个很好的错误:
<!DOCTYPE html>
<html>
<head>
<title>liquid.radio</title>
<link href="/assets/application-c9ed21e2be2e7bb9955d6a0d89357d16.css" media="all" rel="stylesheet" type="text/css" />
<script src="/assets/application-09500810259983928e0b1b4d46b49071.js" type="text/javascript"></script>
<meta content="authenticity_token" name="csrf-param" />
<meta content="MYdcXuDSzYg1qSHrRwx0y0VK5VmqhWmLLGiYSOX7pOI=" name="csrf-token" />
</head>
<body style="background: #FFF;">
<!DOCTYPE html>
<html>
<head>
您的第一部分重复了几次,导致您的HTML无效。
答案 2 :(得分:0)
我使用的是rails 4.2.6。
要解决我的错误,我必须运行以下内容;
rake assets:clean
- 这是为了清理我的资产application.js
文件中的任何问题。这主要是我导入外部js库的顺序。rake assets:precompile
- 这是预编译资产在config/environments/production.rb
中,我必须更改此行
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
到
config.serve_static_files = true
这意味着rails应用程序现在可以提供由assets:precompile
执行此操作并重新启动应用程序后,一切都很顺利!
答案 3 :(得分:0)
我看到的一个问题是,您现在将拥有为您的静态文件提供服务的Rails服务器(puma,unicorn等)。在生产服务器上,您需要服务器(例如Nginx)为这些静态页面提供服务。
如果您的JS / CSS正在开发中,那么您只需要在推送到生产之前运行rake assets:precompile
。然后是配置应用程序服务器以使用生产服务器的问题。