2012-04-16 26 views
0

我試圖部署一個rails應用程序,但我堅持使用資產預編譯錯誤。根據生產日誌,錯誤是由一個名爲screen.css的'Blueprint'css腳本引起的(如您在下面的錯誤輸出中看到的)。但是根據生產日誌,這個資產實際上是預先編譯好的。我試着明確加入screen.css和print.css的預編譯陣列,無論是在application.rb中和配置/環境/ production.rb文件如下來自藍圖的資產預編譯錯誤css - ActionView :: Template :: Error(藍圖/ screen.css沒有預編譯) - 內部服務器錯誤500

config.assets.precompile = %w(screen.css print.css) 

,但無濟於事。我也嘗試過在本地預編譯我的資產,並將所有內容推送到服務器。我試着在這裏列出的所有建議:blueprint/screen.css isn't precompiled 這裏: blueprint css rails 3.1 help 和相同的問題仍然沒有得到解決這裏:Ruby on Rails 3.2 compiled assets are not working

我不知道下一步該怎麼嘗試解決此錯誤。任何幫助將非常感激!日誌輸出如下,以及我的部署文件,cap文件和application.rb文件。預先感謝您的任何建議!

以下是部署後日志文件的一些輸出,您可以在其中看到screen.css被預編譯。錯誤輸出如下:

Compiled application.js (5ms) (pid 16431) 
Compiled jquery.js (2ms) (pid 16431) 
Compiled jquery_ujs.js (0ms) (pid 16431) 
Compiled microposts.js (94ms) (pid 16431) 
Compiled pages.js (1ms) (pid 16431) 
Compiled sessions.js (0ms) (pid 16431) 
Compiled users.js (0ms) (pid 16431) 
Compiled application.css (17ms) (pid 16431) 
Compiled blueprint/ie.css (0ms) (pid 16431) 
Compiled blueprint/plugins/buttons/screen.css (0ms) (pid 16431) 
Compiled blueprint/plugins/fancy-type/screen.css (0ms) (pid 16431) 
Compiled blueprint/plugins/link-icons/screen.css (0ms) (pid 16431) 
Compiled blueprint/plugins/rtl/screen.css (0ms) (pid 16431) 
Compiled blueprint/print.css (0ms) (pid 16431) 
Compiled blueprint/screen.css (0ms) (pid 16431) 
Compiled blueprint/src/forms.css (0ms) (pid 16431) 
Compiled blueprint/src/grid.css (0ms) (pid 16431) 
Compiled blueprint/src/ie.css (0ms) (pid 16431) 
Compiled blueprint/src/print.css (0ms) (pid 16431) 
Compiled blueprint/src/reset.css (0ms) (pid 16431) 
Compiled blueprint/src/typography.css (0ms) (pid 16431) 
Compiled custom.css (0ms) (pid 16431) 
Compiled microposts.css (13ms) (pid 16431) 
Compiled pages.css (1ms) (pid 16431) 
Compiled scaffolds.css (15ms) (pid 16431) 
Compiled sessions.css (1ms) (pid 16431) 
Compiled users.css (1ms) (pid 16431) 

Started GET "/" for 12.13.14.15 at 2012-04-05 14:15:50 -0700 
Processing by PagesController#home as HTML 
Rendered pages/home.html.erb within layouts/application (1.1ms) 
Rendered layouts/_stylesheets.html.erb (1.3ms) 
Completed 500 Internal Server Error in 6ms 

ActionView::Template::Error (blueprint/screen.css isn't precompiled): 
    1: <!--[if lt IE9]> 
    2: <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> 
    3: <![endif]--> 
    4: <%= stylesheet_link_tag 'blueprint/screen', :media => 'screen' %> 
    5: <%= stylesheet_link_tag 'blueprint/print', :media => 'print' %> 
    6: <!--[if lt IE 8]><%= stylesheet_link_tag 'blueprint/ie' %><![endif]--> 
    7: <%= stylesheet_link_tag 'custom', :media => 'screen' %> 
    app/views/layouts/_stylesheets.html.erb:4:in `_app_views_layouts__stylesheets_html_erb___2010157553399413981_33056460' 
    app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__4294160261947576619_31749320' 

而這裏的部署文件:

$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path. 
require "rvm/capistrano"     # Load RVM's capistrano plugin. 
require "bundler/capistrano" 

set :application, "Project" 

set :scm, "git" 
set :repository, "ssh://server.example.ca/usr/local/git_root/project.git" 
set :user, "deploy" 

#set :rvm_bin_path, "/usr/local/rvm/bin" 
set :rvm_ruby_string, "[email protected]" 
set :normalize_asset_timestamps, false 

ssh_options[:forward_agent] = true 

set :branch, "master" 

set :deploy_via, :remote_cache 

# If you aren't deploying to /u/apps/#{application} on the target 
# servers (which is the default), you can specify the actual location 
# via the :deploy_to variable: 
set :deploy_to, "/usr/local/www/sites/project.example.ca/" 

set :use_sudo, false 

set :domain, 'project.example.ca' 

role :app, domain 
role :web, domain 
role :db, domain, :primary => true 

before "deploy:symlink", "assets:precompile" 

namespace :assets do 
    desc "Compile assets" 
    task :precompile, :roles => :app do 
    run "cd #{release_path} && bundle exec rake RAILS_ENV=#{rails_env} assets:precompile" 
    end 
end 

這裏是我的capfile:

load 'deploy' if respond_to?(:namespace) # cap2 differentiator 
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) } 
load 'config/deploy' 
load 'deploy/assets' 

這裏的application.rb中的配置文件:

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

require 'rails/all' 

if defined?(Bundler) 
    # If you precompile assets before deploying to production, use this line 
    Bundler.require(*Rails.groups(:assets => %w(development test))) 
    # If you want your assets lazily compiled in production, use this line 
    # Bundler.require(:default, :assets, Rails.env) 
end 

module Arbiterapi 
    class Application < Rails::Application 

    # Configure the default encoding used in templates for Ruby 1.9. 
    config.encoding = "utf-8" 

    # Configure sensitive parameters which will be filtered from the log file. 
    config.filter_parameters += [:password] 

    # 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' 

    # Precompile problem assets 
    config.assets.precompile = %w(screen.css print.css) 

    end 
end 
+0

你能在你的application.css中顯示什麼嗎?也許你沒有添加所有必需的CSS文件。你可以嘗試在本地開發機器上運行這個'bundle exec rake assets:precompile',然後將整個公用文件夾複製到生產服務器。也作爲最後的手段嘗試在config/environments/production.rb中將config.assets.compile設置爲true。 – Sebi 2012-05-10 06:31:37

+0

我的application.css文件是空的,除了這個自動生成的註釋:/ * *這是一個清單文件,它將自動包含目錄 *和所有子目錄中可用的所有樣式表。您可以自由地爲該文件添加應用程序範圍的樣式,並且它們將出現在編譯文件的頂部 *,但通常最好爲每個樣式範圍創建一個新文件。 * = require_self * = require_tree。 */ – 2012-05-10 18:57:38

+0

我也已經試過通過'bundle exec rake assets:precompile'在本地機器上預編譯資源,然後將我的git存儲庫推送到遠程服務器,然後運行'cap deploy:update'。在此之後,所有預編譯的資產都應該位於我的網絡服務器上的公共文件夾中。 – 2012-05-10 19:03:14

回答

0

我遇到了同樣的問題。但事實證明,我的遺失資產被編譯到application.js中(因爲它合併了所有文件),所以我只需刪除對特定文件(在我的情況下是webcam.js)的引用。

你的文件被合併到application.css等...

相關問題