2012-02-24 5 views
0

Я боролся с этим в течение некоторого времени, и я просто не могу найти сообщение, которое имеет такую ​​же проблему, как и моя. Я новичок в работе с Heroku и Rails, и я пытаюсь выяснить, как заставить конвейер активов работать с css-файлом, который есть в каталоге «App/assets/stylesheets». Я пробовал следующие сообщения от http://guides.rubyonrails.org/asset_pipeline.html и http://www.youtube.com/watch?v=p_3dIPgXgkg, но я не могу понять, как заставить Heroku развернуть очень простой сайт с новым css-файлом. Я проверял, что проблема связана с конвейером, отключая конвейер, и Heroku развертывает его просто отлично. Мой локальный сервер использует CSS очень просто, поэтому проблема должна быть в моих настройках с конвейером активов.

Я создал новый файл css в следующем месте: «app/assets/stylesheets/custom.css»

Вот как выглядит содержимое файла манифеста в «app/assets/stylesheets/application.css», :heroku - rails 3.1 - конвейер активов

/* 
* This is a manifest file that'll automatically include all the stylesheets available in this directory 
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at 
* the top of the compiled file, but it's generally better to create a new file per style scope. 
*= require_self 
*= require_tree . 
*/ 

Вот что мой файл "конфигурации/application.rb" выглядит следующим образом:

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


# Pick the frameworks you want: 
require "active_record/railtie" 
require "action_controller/railtie" 
require "action_mailer/railtie" 
require "active_resource/railtie" 
require "sprockets/railtie" 
# require "rails/test_unit/railtie" 

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 MegaProject 
    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. 

    # Custom directories with classes and modules you want to be autoloadable. 
    # config.autoload_paths += %W(#{config.root}/extras) 

    # Only load the plugins named here, in the order given (default is alphabetical). 
    # :all can be used as a placeholder for all plugins not explicitly named. 
    # config.plugins = [ :exception_notification, :ssl_requirement, :all ] 

    # Activate observers that should always be running. 
    # config.active_record.observers = :cacher, :garbage_collector, :forum_observer 

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

    # 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 

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


Я использую «рубин 1.9.2p290 (2011-07-09 ревизии 32553) [ x86_64-darwin11.1.0] "on" Rails 3.1.3 "

И, наконец, вот посмотрите на мой Gemfile:

source 'http://rubygems.org' 

gem 'rails', '3.1.3' 
gem 'sqlite3' 
gem 'jquery-rails' 

# Bundle edge Rails instead: 
# gem 'rails',  :git => 'git://github.com/rails/rails.git' 

# Gems used only for assets and not required 
# in production environments by default. 
group :assets do 
    gem 'sass-rails', '~> 3.1.5' 
    gem 'coffee-rails', '~> 3.1.1' 
    gem 'uglifier', '>= 1.0.3' 
end 

group :production do 
    gem 'pg' 
end 

# To use ActiveModel has_secure_password 
# gem 'bcrypt-ruby', '~> 3.0.0' 

# Use unicorn as the web server 
# gem 'unicorn' 

# Deploy with Capistrano 
# gem 'capistrano' 

# To use debugger 
# gem 'ruby-debug19', :require => 'ruby-debug' 



Может кто-нибудь помочь мне с этим? Спасибо, Николай Кинкейд

Вот выход из запроса j_mcnally в:

Nicholass-MacBook-Pro:mega_project nbkincaid$ git push heroku master 
Counting objects: 9, done. 
Delta compression using up to 4 threads. 
Compressing objects: 100% (5/5), done. 
Writing objects: 100% (5/5), 513 bytes, done. 
Total 5 (delta 4), reused 0 (delta 0) 

-----> Heroku receiving push 
-----> Removing .DS_Store files 
-----> Ruby/Rails app detected 
-----> Detected Rails is not set to serve static_assets 
     Installing rails3_serve_static_assets... done 
-----> Configure Rails 3 to disable x-sendfile 
     Installing rails3_disable_x_sendfile... done 
-----> Configure Rails to log to stdout 
     Installing rails_log_stdout... done 
-----> Gemfile detected, running Bundler version 1.0.7 
     Unresolved dependencies detected; Installing... 
     Using --without development:test 
     Fetching source index for http://rubygems.org/ 
     Installing rake (0.9.2.2) 
     Installing multi_json (1.1.0) 
     Installing activesupport (3.1.3) 
     Installing builder (3.0.0) 
     Installing i18n (0.6.0) 
     Installing activemodel (3.1.3) 
     Installing erubis (2.7.0) 
     Installing rack (1.3.6) 
     Installing rack-cache (1.1) 
     Installing rack-mount (0.8.3) 
     Installing rack-test (0.6.1) 
     Installing hike (1.2.1) 
     Installing tilt (1.3.3) 
     Installing sprockets (2.0.3) 
     Installing actionpack (3.1.3) 
     Installing mime-types (1.17.2) 
     Installing polyglot (0.3.3) 
     Installing treetop (1.4.10) 
     Installing mail (2.3.0) 
     Installing actionmailer (3.1.3) 
     Installing arel (2.2.2) 
     Installing tzinfo (0.3.31) 
     Installing activerecord (3.1.3) 
     Installing activeresource (3.1.3) 
     Installing coffee-script-source (1.2.0) 
     Installing execjs (1.3.0) 
     Installing coffee-script (2.2.0) 
     Installing rack-ssl (1.3.2) 
     Installing json (1.6.5) with native extensions 
     Installing rdoc (3.12) 
     Installing thor (0.14.6) 
     Installing railties (3.1.3) 
     Installing coffee-rails (3.1.1) 
     Installing jquery-rails (1.0.19) 
     Installing pg (0.13.1) with native extensions 
     Using bundler (1.0.7) 
     Installing rails (3.1.3) 
     Installing sass (3.1.15) 
     Installing sass-rails (3.1.5) 
     Installing sqlite3 (1.3.5) with native extensions 
     Installing uglifier (1.2.3) 
     Your bundle is complete! It was installed into ./.bundle/gems/ 
-----> Compiled slug size is 7.0MB 
-----> Launching... done, v27 
     http://strong-moon-9939.heroku.com deployed to Heroku 

To [email protected]:strong-moon-9939.git 
    95351fa..8e4131f master -> master 


Вот что регистрирует Heroku сообщения дают мне:

2012-02-24T06:57:43+00:00 heroku[router]: GET strong-moon-9939.heroku.com/ dyno=web.1 queue=0 wait=0ms service=7ms status=500 bytes=728 
2012-02-24T06:57:43+00:00 heroku[nginx]: 24.13.158.102 - - [24/Feb/2012:06:57:43 +0000] "GET/HTTP/1.1" 500 728 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11" strong-moon-9939.heroku.com 
2012-02-24T06:58:38+00:00 app[web.1]: 
2012-02-24T06:58:38+00:00 app[web.1]: 
2012-02-24T06:58:38+00:00 app[web.1]: Started GET "/" for 24.13.158.102 at 2012-02-23 22:58:38 -0800 
2012-02-24T06:58:38+00:00 app[web.1]: Processing by UsersController#home as HTML 
2012-02-24T06:58:38+00:00 app[web.1]: Rendered users/home.html.erb within layouts/application (0.0ms) 
2012-02-24T06:58:38+00:00 app[web.1]: Completed 500 Internal Server Error in 2ms 
2012-02-24T06:58:38+00:00 app[web.1]: 
2012-02-24T06:58:38+00:00 app[web.1]: ActionView::Template::Error (custom.css isn't precompiled): 
2012-02-24T06:58:38+00:00 app[web.1]:  3: <head> 
2012-02-24T06:58:38+00:00 app[web.1]:  4: <title><%= title %></title> 
2012-02-24T06:58:38+00:00 app[web.1]:  5: <%= stylesheet_link_tag "application" %> 
2012-02-24T06:58:38+00:00 app[web.1]:  6: <%= stylesheet_link_tag "custom" %> 
2012-02-24T06:58:38+00:00 app[web.1]:  7: <%= javascript_include_tag "application" %> 
2012-02-24T06:58:38+00:00 app[web.1]:  8: <%= csrf_meta_tags %> 
2012-02-24T06:58:38+00:00 app[web.1]:  9: </head> 
2012-02-24T06:58:38+00:00 app[web.1]: app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__150896894354786412_13162880' 
2012-02-24T06:58:38+00:00 app[web.1]: 
2012-02-24T06:58:38+00:00 app[web.1]: 
2012-02-24T06:58:38+00:00 app[web.1]: cache: [GET /] miss 
2012-02-24T06:58:38+00:00 heroku[router]: GET strong-moon-9939.heroku.com/ dyno=web.1 queue=0 wait=0ms service=7ms status=500 bytes=728 
2012-02-24T06:58:38+00:00 heroku[nginx]: 24.13.158.102 - - [24/Feb/2012:06:58:38 +0000] "GET/HTTP/1.1" 500 728 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11" strong-moon-9939.heroku.com 
+0

ли ваша рейк-задача прерывается при развертывании героку? –

ответ

0

Хорошо, я, наконец, понял это. Просмотрев http://guides.rubyonrails.org/asset_pipeline.html еще немного, я понял, что мне нужно добавить в:

//= require custom 

в файл application.css. Я ввел это за пределами комментариев, и это устранило мою проблему. Я смог прекомпилировать локально, и после этого все отлично работало на Heroku. Спасибо всем, кто помог мне туда добраться.

+0

рад, что у тебя это получилось –

1

Добавить это application.rb

config.assets.initialize_on_precompile = false

+0

Спасибо, j_mcnally. Я попробовал это, но, похоже, это не трюк. – nbkincaid

+0

Все команды сработали отлично после того, как я попробовал это, я могу прекомпилировать, и это подтолкнет герою, и все работает хорошо. – nbkincaid

+0

можете ли вы опубликовать выходные данные из вашего развертывания? –

2

Так что я не уверен, но может быть, что вы развернулись в неправильной среде Heroku. Чтобы использовать конвейер активов, рельсы 3.1 вещи, которые вы должны были сделать геройку кедра окружающей среды. посмотреть сайт Heroku Подробности

http://devcenter.heroku.com/articles/rails3x-asset-pipeline-cedar

цитата из этого сайта

Хотя Rails 3.1 и 3.2 может работать в стеке Бамбуковый без трубопровода активов, эти версии Rails лучше всего работает на Cedar Heroku в стек. Для новых пользователей мы рекомендуем прочитать наше руководство по созданию приложения Rails 3.0 на Cedar, прежде чем продолжить.

+0

Спасибо, Mgrandjean, этот помог мне приблизиться, но я все еще получаю ошибку, показанную в журналах heroku после того, как пробовал много разных итераций. Я закончил тем, что поставил все свои css в файл application.css, и теперь он отлично работает на героку. Из того, что я читал, похоже, что конвейер ресурсов завершает все это вместе, так что, если он заканчивается тем же, я в порядке с ним сейчас. В конце концов, появится прямой способ добавления дополнительных файлов активов, и я перейду на стилистически правильный путь. – nbkincaid

Смежные вопросы