rails 4无法在heroku

时间:2015-06-23 13:51:32

标签: ruby-on-rails heroku assets

heroku不会创建application.js和application.css资产 但是本地它可以使用RAILS_ENV =生产包exec rake资产:预编译

$ heroku run bash
Running `bash` attached to terminal... up, run.9223
~ $ ls public/assets/
bootstrap                          fontawesome-webfont-357f2cccb6b6fe8870c1958cd832e28b.svg
chosen-sprite-29932c6105dc0df4193eda202a5dbd78.png     fontawesome-webfont-4929d0fe3a09ebec3445c48918ef3bfe.eot
chosen-sprite@2x-9df686b038761553897bbd9085c962ac.png  fontawesome-webfont-82b6c6fcda29095350320a3997bc3775.svg
chosen-sprite@2x-decb685351b5a2b482385e7391ba8c91.png  fontawesome-webfont-9690a9ba78d5f496a8868339359f25c0.woff
chosen-sprite@2x.png                       fontawesome-webfont-a26d97cd46e898de1e14528a562b8fb6.ttf
chosen-sprite-63013ff1d1dcdc2707aa16953b67d3fe.png     fontawesome-webfont-b6f189d6a6c9d07af5b6fdf0ef2c1650.ttf
chosen-sprite.png                      fontawesome-webfont-c035b5ac9c359ad80538f56da1547393.woff
ckeditor                           fontawesome-webfont-fbb0572830801c0b3b7d948a2bf63706.eot
FontAwesome-797ea6c3c8de5369b78e6c89413b51a4.otf       jquery-ui
FontAwesome-902c76c51c79feda3a5f8b2ac2b70810.otf       manifest-f3434d90088642197e491048c55d13f8.json

我的应用配置:

应用程序/资产/ Javascript角/ application.js中

//= require jquery
//= require jquery_ujs
//= require jquery-ui/autocomplete
//= require moment
//= require chosen-jquery
//= require chosen_select
//= require ckeditor/init
//= require bootstrap
//= require bootstrap-datetimepicker
//= require bootstrapValidator.min
//= require jquery.tokeninput
//= require pluralize
//= require charges
//= require chosen_select
//= require crawlers
//= require cvs
//= require dfp
//= require job_alerts
//= require jobs
//= require jobupdates
//= require jquery.selection
//= validations

$(function() {
  $('#dpcomjob').datetimepicker({ pickTime: false });
});

配置/ application.rb中

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

Bundler.require(:default, Rails.env)

module Clm14
  class Application < Rails::Application
    config.autoload_paths << Rails.root.join("lib")
    config.autoload_paths << Rails.root.join("app/workers")
    config.assets.precompile += Ckeditor.assets
  end
end

配置/环境/ production.rb

Clm14::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

  # Eager load code on boot. This eager loads most of Rails and
  # your application in memory, allowing both thread web servers
  # and those relying on copy on write to perform better.
  # Rake tasks automatically ignore this option for performance.
  config.eager_load = true

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

  # Enable Rack::Cache to put a simple HTTP cache in front of your application
  # Add `rack-cache` to your Gemfile before enabling this.
  # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
  # config.action_dispatch.rack_cache = 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.js_compressor = :uglifier
  # config.assets.css_compressor = :sass

  # Do not fallback to assets pipeline if a precompiled asset is missed.
  config.assets.compile = false

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

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

  # 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

  # Set to :debug to see everything in the log.
  config.log_level = :info

  # 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://assets.example.com"

  # Precompile additional assets.
  # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
  # config.assets.precompile += %w( search.js )

  # Ignore bad email addresses and do not raise email delivery errors.
  # Set this to true and configure the email server for immediate delivery to raise delivery errors.
  # config.action_mailer.raise_delivery_errors = false
  config.action_mailer.smtp_settings = {
    :address        => ENV['SMTP_SERVER'],
   :port           => ENV['SMTP_PORT'],
    :authentication => :plain,
    :user_name      => ENV['SMTP_LOGIN'],
    :password       => ENV['SMTP_PASSWORD'],
    :domain         => ENV['DOMAIN_NAME']
  }
  config.action_mailer.default_url_options = { :host => ENV['DOMAIN_NAME'] }
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = false
  config.action_mailer.default :charset => "utf-8"

  # 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

  # Disable automatic flushing of the log to improve performance.
  # config.autoflush_log = false

  # Use default logging formatter so that PID and timestamp are not suppressed.
  config.log_formatter = ::Logger::Formatter.new

  config.paperclip_defaults = {
  :storage => :s3,
  :s3_credentials => {
    :bucket => ENV['S3_BUCKET_NAME'],
      :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
      :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
    },
  :path => '/:class/:attachment/:id_partition/:style/:filename',
  :url => ':s3_domain_url'
  }

end

部署日志

git pus heroku master
Writing objects: 100% (6/6), 494 bytes | 0 bytes/s, done.
Total 6 (delta 5), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Deleting 3 files matching .slugignore patterns.
remote: -----> Removing .DS_Store files
remote: -----> Fetching custom git buildpack... done
remote: -----> Multipack app detected
remote: =====> Downloading Buildpack: https://github.com/stomita/heroku-buildpack-phantomjs.git
remote: =====> Detected Framework: PhantomJS
remote: -----> Extracting PhantomJS 1.9.8 binaries to /tmp/build_c80749a2a9158a2d2006e2440ef8287b/vendor/phantomjs
remote: -----> exporting PATH and LIBRARY_PATH
remote: =====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-ruby.git
remote: =====> Detected Framework: Ruby
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.0.0
remote: -----> Installing dependencies using 1.9.7
remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        Rubygems 2.0.14 is not threadsafe, so your gems must be installed one at a time. Upgrade to Rubygems 2.1.0 or higher to enable p
arallel gem installation.
remote:        Using rake 10.4.2
remote:        Using i18n 0.7.0
remote:        Using json 1.8.3
remote:        Using minitest 5.7.0
remote:        Using thread_safe 0.3.5
remote:        Using tzinfo 1.2.2
remote:        Using activesupport 4.1.11
remote:        Using builder 3.2.2
remote:        Using erubis 2.7.0
remote:        Using actionview 4.1.11
remote:        Using rack 1.5.5
remote:        Using rack-test 0.6.3
remote:        Using actionpack 4.1.11
remote:        Using mime-types 1.25.1
remote:        Using mail 2.6.3
remote:        Using actionmailer 4.1.11
remote:        Using activemodel 4.1.11
remote:        Using actionmailer 4.1.11
remote:        Using activemodel 4.1.11
remote:        Using arel 5.0.1.20140414130214
remote:        Using activerecord 4.1.11
remote:        Using addressable 2.3.6
remote:        Using gyoku 1.2.2
remote:        Using mini_portile 0.6.1
remote:        Using nokogiri 1.6.5
remote:        Using akami 1.2.2
remote:        Using ancestry 2.1.0
remote:        Using aws-sdk-v1 1.59.1
remote:        Using aws-sdk 1.59.1
remote:        Using bcrypt 3.1.9
remote:        Using bonsai-elasticsearch-rails 0.0.4
remote:        Using sass 3.2.2
remote:        Using bootstrap-sass 3.1.1.1
remote:        Using thor 0.19.1
remote:        Using railties 4.1.11
remote:        Using jquery-rails 3.0.4
remote:        Using bootstrap-validator-rails 0.5.3
remote:        Using momentjs-rails 2.5.1
remote:        Using bootstrap3-datetimepicker-rails 3.0.0.2
remote:        Using buftok 0.2.0
remote:        Using cancancan 1.9.2
remote:        Using xpath 2.0.0
remote:        Using capybara 2.4.4
remote:        Using hitimes 1.2.2
remote:        Using timers 4.0.1
remote:        Using celluloid 0.16.0
remote:        Using coffee-script-source 1.9.1.1
remote:        Using execjs 2.5.2
remote:        Using coffee-script 2.4.1
remote:        Using coffee-rails 4.1.0
remote:        Using chunky_png 1.3.3
remote:        Using fssm 0.2.10
remote:        Using compass 0.12.2
remote:        Using compass-rails 2.0.0
remote:        Using hike 1.2.3

remote:        Using multi_json 1.11.1
remote:        Using tilt 1.4.1
remote:        Using sprockets 2.12.3
remote:        Using sprockets-rails 2.3.1
remote:        Using sass-rails 4.0.5
remote:        Using chosen-rails 1.2.0
remote:        Using chronic 0.10.2
remote:        Using cities 0.3.1
remote:        Using climate_control 0.0.3
remote:        Using cocaine 0.5.5
remote:        Using orm_adapter 0.5.0
remote:        Using ckeditor 4.1.1
remote:        Using cliver 0.3.2
remote:        Using clockwork 1.2.0
remote:        Using connection_pool 2.1.0
remote:        Using currencies 0.4.2
remote:        Using countries 0.9.3 from git://github.com/hexorx/countries.git (at master)
remote:        Using descendants_tracker 0.0.4
remote:        Using responders 1.1.2
remote:        Using warden 1.2.3
remote:        Using devise 3.4.1
remote:        Using unf_ext 0.0.6
remote:        Using unf 0.1.4
remote:        Using domain_name 0.5.23
remote:        Using elasticsearch-api 1.0.6
remote:        Using multipart-post 1.2.0
remote:        Using faraday 0.8.9
remote:        Using elasticsearch-transport 1.0.6
remote:        Using elasticsearch 1.0.6
remote:        Using hashie 3.3.2
remote:        Using elasticsearch-model 0.1.6
remote:        Using elasticsearch-rails 0.1.6
remote:        Using equalizer 0.0.9
remote:        Using excon 0.42.1
remote:        Using feralchimp 1.0.1
remote:        Using figaro 1.0.0
remote:        Using flexslider 2.2.0
remote:        Using tilt 1.4.1
remote:        Using sprockets 2.12.3
remote:        Using sprockets-rails 2.3.1
remote:        Using sass-rails 4.0.5
remote:        Using chosen-rails 1.2.0
remote:        Using chronic 0.10.2
remote:        Using cities 0.3.1
remote:        Using climate_control 0.0.3
remote:        Using cocaine 0.5.5
remote:        Using orm_adapter 0.5.0
remote:        Using ckeditor 4.1.1
remote:        Using cliver 0.3.2
remote:        Using clockwork 1.2.0
remote:        Using connection_pool 2.1.0
remote:        Using currencies 0.4.2
remote:        Using countries 0.9.3 from git://github.com/hexorx/countries.git (at master)
remote:        Using descendants_tracker 0.0.4
remote:        Using responders 1.1.2
remote:        Using warden 1.2.3
remote:        Using devise 3.4.1
remote:        Using unf_ext 0.0.6
remote:        Using unf 0.1.4
remote:        Using domain_name 0.5.23
remote:        Using elasticsearch-api 1.0.6
remote:        Using multipart-post 1.2.0
remote:        Using faraday 0.8.9
remote:        Using elasticsearch-transport 1.0.6
remote:        Using elasticsearch 1.0.6
remote:        Using hashie 3.3.2
remote:        Using elasticsearch-model 0.1.6
remote:        Using elasticsearch-rails 0.1.6
remote:        Using equalizer 0.0.9
remote:        Using excon 0.42.1
remote:        Using feralchimp 1.0.1
remote:        Using figaro 1.0.0
remote:        Using flexslider 2.2.0
remote:        Using font-awesome-rails 4.2.0.0
remote:        Using geocoder 1.2.8
remote:        Using request_store 1.1.0
remote:        Using gon 5.2.3
remote:        Using multi_xml 0.5.5
remote:        Using httparty 0.13.3
remote:        Using googl 0.7.0
remote:        Using heroku-api 0.3.21
remote:        Using http_parser.rb 0.6.0
remote:        Using http 0.5.1
remote:        Using http-cookie 1.0.2
remote:        Using httpi 2.3.0
remote:        Using jbuilder 1.0.2
remote:        Using jquery-ui-rails 5.0.3
remote:        Using libv8 3.16.14.7
remote:        Using systemu 2.6.4
remote:        Using macaddr 1.7.1
remote:        Using mail_view 2.0.4
remote:        Using net-http-digest_auth 1.4
remote:        Using net-http-persistent 2.9.4
remote:        Using ntlm-http 0.1.1
remote:        Using webrobots 0.1.1
remote:        Using mechanize 2.7.2
remote:        Using memoizable 0.4.2
remote:        Using netrc 0.10.3
remote:        Using newrelic_rpm 3.9.8.273
remote:        Using nilify_blanks 1.2.0
remote:        Using nori 2.4.0
remote:        Using paperclip 4.2.1
remote:        Using pdf-core 0.4.0
remote:        Using pg 0.15.1
remote:        Using websocket-extensions 0.1.2
remote:        Using websocket-driver 0.5.4
remote:        Using poltergeist 1.6.0
remote:        Using ttfunk 1.4.0
remote:        Using prawn 1.3.0
remote:        Using prawn-table 0.2.1
remote:        Using bundler 1.9.7
remote:        Using rails 4.1.11
remote:        Using prawn-rails 0.1.0 from git://github.com/cortiz/prawn-rails.git (at master)
remote:        Using puma 2.11.2
remote:        Using rack-protection 1.5.3
remote:        Using rails_serve_static_assets 0.0.4
remote:        Using rails_stdout_logging 0.0.3
remote:        Using rails_12factor 0.0.3
remote:        Using rdoc 3.12.2
remote:        Using redis 3.2.0
remote:        Using redis-namespace 1.5.1
remote:        Using ref 1.0.5
remote:        Using rest-client 1.8.0
remote:        Using rubyntlm 0.4.0
remote:        Using uuid 2.3.7
remote:        Using wasabi 3.3.0
remote:        Using savon 2.8.0
remote:        Using sdoc 0.3.20
remote:        Using sequenced 2.0.0
remote:        Using sidekiq 3.3.0
remote:        Using simple_form 3.1.0
remote:        Using simple_oauth 0.2.0
remote:        Using sinatra 1.4.6
remote:        Using smarter_csv 1.0.19
remote:        Using stripe 1.20.4 from git://github.com/stripe/stripe-ruby.git (at master)
remote:        Using therubyracer 0.12.1
remote:        Using twitter 5.5.1
remote:        Using uglifier 2.1.2
remote:        Using valvat 0.6.7 from git://github.com/yolk/valvat.git (at master)
remote:        Using whenever 0.9.4
remote:        Using wicked 1.1.0
remote:        Using will_paginate 3.0.7
remote:        Using will_paginate-bootstrap 1.0.1
remote:        Using wombat 2.3.0
remote:        Bundle complete! 85 Gemfile dependencies, 161 gems now installed.
remote:        Gems in the groups development and test were not installed.
remote:        Bundled gems are installed into ./vendor/bundle.
remote:        Bundle completed (1.08s)
remote:        Cleaning up the bundler cache.
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        Starting up a new ElasticSearch client with https://51drn9f1:cp640jduccb87ncf@smoke-2371997.eu-west-1.bonsai.io
remote:        cp public/assets/chosen-sprite@2x-decb685351b5a2b482385e7391ba8c91.png public/assets/chosen-sprite@2x.png
remote:        cp public/assets/chosen-sprite-29932c6105dc0df4193eda202a5dbd78.png public/assets/chosen-sprite.png
remote:        cp public/assets/chosen-sprite-63013ff1d1dcdc2707aa16953b67d3fe.png public/assets/chosen-sprite.png
remote:        cp public/assets/chosen-sprite@2x-9df686b038761553897bbd9085c962ac.png public/assets/chosen-sprite@2x.png
remote:        cp public/assets/chosen-sprite-59a0887fcec16b01139f039d1fc37de5.png public/assets/chosen-sprite.png
remote:        cp public/assets/chosen-sprite@2x-cf6654d42814ca9f47e6ea8af6103e56.png public/assets/chosen-sprite@2x.png
remote:        cp public/assets/ckeditor/skins/moono/icons_hidpi-c6bf4120f67e2c0dd1853971ae4d47f1.png public/assets/ckeditor/skins/moono/icons_hidpi.png
remote:        cp public/assets/ckeditor/skins/moono/icons-acf6188db5b2708a39e285816e484d49.png public/assets/ckeditor/skins/moono/icons.png
remote:        cp public/assets/ckeditor/skins/moono/icons_hidpi-8067e9a92925c876d708910b49c817d2.png public/assets/ckeditor/skins/moono/icons_hidpi.png
remote:        cp public/assets/ckeditor/skins/moono/icons_hidpi-ca2c8503d5405bd4a34620d7da35c72e.png public/assets/ckeditor/skins/moono/icons_hidpi.png
remote:        cp public/assets/ckeditor/skins/moono/icons-acff3bd417155aac567347cd3e7eab32.png public/assets/ckeditor/skins/moono/icons.png
remote:        cp public/assets/ckeditor/skins/moono/icons-15e90c8816d61e8ebd5832b9aa414092.png public/assets/ckeditor/skins/moono/icons.png
remote:        Asset precompilation completed (11.90s)
remote:        Cleaning assets
remote:        Running: rake assets:clean
remote:        Starting up a new ElasticSearch client with https://51drn9f1:cp640jduccb87ncf@smoke-2371997.eu-west-1.bonsai.io
remote:
remote: Using release configuration from last framework (Ruby).
remote: -----> Discovering process types
remote:        Procfile declares types     -> web, worker
remote:        Default types for Multipack -> console, rake
remote:
remote: -----> Compressing... done, 126.8MB
remote: -----> Launching... done, v93

remote:
remote: Verifying deploy.... done.
To git@heroku.com:coffeelovesmilk-staging.git
 + b252552...41ea616 crawler_stabilization_1 -> master (forced update)

1 个答案:

答案 0 :(得分:0)

在我的.slugignore文件行/app/assets/中找到,因此heroku忽略了资产。我删除了这一行,资产运作良好。