0

我在这个智慧的结尾。似乎所有新的rails应用程序我都在environments/production.rb中设置了几个配置,部署并继续我的生活。但是现在我们正在将几个Rails应用程序迁移到新的服务器上,而且在部署到生产环境时似乎所有人都有这个问题。Rails 3.2生产中的资产

似乎正在发生的事情是,我的JavaScript或样式表都没有被编译。而且我看不到应用程序的样式,而JavaScript不起作用。

的config/application.rb中:

require File.expand_path('../boot', __FILE__) 
require 'rails/all' 

if defined?(Bundler) 
    Bundler.require(:default, :assets, Rails.env) 
end 

module MyApp 
    class Application < Rails::Application 
    ... omitted code ... 
    # Enable the asset pipeline 
    config.assets.enabled = true 

    # Version of your assets, change this if you want to expire all your assets 
    config.assets.version = '1.0' 


    config.generators.stylesheet_engine = :scss 
    end 
end 

配置/环境/ production.rb:

MyApp::Application.configure do 

    # 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 = true 

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

    ... omitted code ... 
end 

在我的应用程序 - < ...> JS:

// This is a manifest file that'll be compiled into including all the files listed below. 
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically 
// be included in the compiled file accessible from  http://example.com/assets/application.js 
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 
// the compiled file. 
// 
//= require jquery 
//= require jquery_ujs 
//= require_tree 
; 

和我的应用程序-< ...> .css是完全空的。我错过了什么?

+0

有什么问题?我假设造型没有被反映到开发生产服务器? – coletrain

+0

嘿,你有没有在你的新服务器上设置javascript env来编译你的资产? (例如nodejs)。如果没有将therubyracer添加到您的Gemfile中并进行测试。 – cristian

+0

是的CSS和JavaScript都不能在生产中工作。我使用'therubyracer'gem作为资产 'gem'execjs',gem'therubyracer',:platforms =>:ruby gem'libv8','3.3.10.4'' – Sparkmasterflex

回答

0

因此,昨天过了大半天,今天大约一个小时,我突然意识到了一些事情......我之前遇到过这个问题。

果然......将rails更新到3.2.14并再次部署固定了整个事情。