在heroku上部署rails app的问题

时间:2017-11-16 16:20:24

标签: css ruby-on-rails ruby heroku

我是rails的新手,我正在编写代码。该网站在我的本地工作完美,但在heroku上远程部署时,似乎找不到css文件。

我正在使用ruby 2.4Rails 5.0gemfile

运行应用
source 'https://rubygems.org' 

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end

gem 'bootstrap-sass', '~> 3.3', '>= 3.3.7'
gem 'autoprefixer-rails'
gem 'font-awesome-rails', '~> 4.6', '>= 4.6.3.1'
gem 'animate-rails', '~> 1.0', '>= 1.0.10'
gem 'owlcarousel-rails', '~> 1.1', '>= 1.1.3.3'
gem 'wow-rails', '~> 0.0.1'
gem 'magnific-popup-rails', '~> 1.1'
gem 'google-api-client', '~> 0.12.0'
gem 'figaro'
# cron task
gem 'whenever', require: false
# Authentication
gem 'devise'
gem 'cancancan', '~> 1.15'
# serach and autocompletion
gem 'pg_search'
# mailer dev
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.3'
# Use sqlite3 as the database for Active Record
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'jquery-ui-rails', '~> 5.0'
gem 'rails_admin', :git => 'git://github.com/sferik/rails_admin.git'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
#gem 'capistrano3-puma', github: "seuros/capistrano-puma"

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  # Use Capistrano for deployment
  gem 'capistrano'
  gem 'capistrano-rails'
  gem 'capistrano-rvm'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

ruby "2.4.1"

通过命令heroku log --tail

输入日志
2017-11-16T16:07:52.898937+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 6818 -e production`
2017-11-16T16:07:58.371812+00:00 app[web.1]: => Booting Puma
2017-11-16T16:07:58.371821+00:00 app[web.1]: => Rails 5.0.6 application starting in production on http://0.0.0.0:6818
2017-11-16T16:07:58.371822+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-11-16T16:07:58.371822+00:00 app[web.1]: Puma starting in single mode...
2017-11-16T16:07:58.371827+00:00 app[web.1]: * Version 3.10.0 (ruby 2.4.1-p111), codename: Russell's Teapot
2017-11-16T16:07:58.371828+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-11-16T16:07:58.371828+00:00 app[web.1]: * Environment: production
2017-11-16T16:07:58.371978+00:00 app[web.1]: * Listening on tcp://0.0.0.0:6818
2017-11-16T16:07:58.372379+00:00 app[web.1]: Use Ctrl-C to stop
2017-11-16T16:07:58.939021+00:00 heroku[web.1]: State changed from starting to up
2017-11-16T16:07:59.757157+00:00 app[web.1]: I, [2017-11-16T16:07:59.757044 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3] Started GET "/" for 80.12.27.252 at 2017-11-16 16:07:59 +0000
2017-11-16T16:07:59.766621+00:00 app[web.1]: I, [2017-11-16T16:07:59.766547 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3]   Rendering pages/index.html.erb within layouts/application
2017-11-16T16:07:59.763739+00:00 app[web.1]: I, [2017-11-16T16:07:59.763642 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3] Processing by PagesController#index as HTML
2017-11-16T16:07:59.767481+00:00 app[web.1]: I, [2017-11-16T16:07:59.767416 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3]   Rendered pages/index.html.erb within layouts/application (0.7ms)
2017-11-16T16:07:59.936841+00:00 app[web.1]: I, [2017-11-16T16:07:59.936713 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3]   Rendered layouts/_nav.html.erb (0.4ms)
2017-11-16T16:07:59.941558+00:00 app[web.1]: I, [2017-11-16T16:07:59.941458 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3]   Rendered layouts/_footer.html.erb (4.1ms)
2017-11-16T16:07:59.941919+00:00 app[web.1]: I, [2017-11-16T16:07:59.941858 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3] Completed 200 OK in 178ms (Views: 177.2ms)
2017-11-16T16:07:59.942814+00:00 heroku[router]: at=info method=GET path="/" host=mysterious-crag-68857.herokuapp.com request_id=b03307de-5170-474a-9f27-50cd05bf07a3 fwd="80.12.27.252" dyno=web.1 connect=0ms service=190ms status=200 bytes=14894 protocol=https
2017-11-16T16:08:00.224613+00:00 heroku[router]: at=info method=GET path="/assets/application-cbd352f84234371962220aac536e7439e570099d31857c088b4e6d82141e9206.css" host=mysterious-crag-68857.herokuapp.com request_id=d2c6dfd6-4660-4844-9d44-143e3d21b917 fwd="80.12.27.252" dyno=web.1 connect=5ms service=10ms status=200 bytes=290 protocol=https
2017-11-16T16:08:00.469689+00:00 heroku[router]: at=info method=GET path="/assets/fondation_pierre_fabre.png" host=mysterious-crag-68857.herokuapp.com request_id=c7adcbdd-8478-4916-9aff-0a90a52058bc fwd="80.12.27.252" dyno=web.1 connect=0ms service=8ms status=200 bytes=3889 protocol=https
2017-11-16T16:08:00.354457+00:00 heroku[router]: at=info method=GET path="/assets/logo2.png" host=mysterious-crag-68857.herokuapp.com request_id=720bf865-6dc4-401f-aac2-bf8eb96c5e90 fwd="80.12.27.252" dyno=web.1 connect=0ms service=5ms status=200 bytes=15746 protocol=https
2017-11-16T16:08:00.331984+00:00 heroku[router]: at=info method=GET path="/assets/application-7a19b05aebcc1264ba7bc75e8a9ab79af4669370f312952095c90b8160480841.js" host=mysterious-crag-68857.herokuapp.com request_id=c58820a6-ce78-43d8-b9da-f188ab36a9d4 fwd="80.12.27.252" dyno=web.1 connect=0ms service=3ms status=200 bytes=303 protocol=https
2017-11-16T16:08:00.351225+00:00 app[web.1]: I, [2017-11-16T16:08:00.351111 #4]  INFO -- : [720bf865-6dc4-401f-aac2-bf8eb96c5e90] Started GET "/assets/logo2.png" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:00.464437+00:00 app[web.1]: I, [2017-11-16T16:08:00.464337 #4]  INFO -- : [62f2a2a3-392b-446d-be9b-a32e38f68397] Started GET "/assets/single_folio/featured1.jpg" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:00.465587+00:00 app[web.1]: I, [2017-11-16T16:08:00.464658 #4]  INFO -- : [c7adcbdd-8478-4916-9aff-0a90a52058bc] Started GET "/assets/fondation_pierre_fabre.png" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:00.582164+00:00 app[web.1]: I, [2017-11-16T16:08:00.582059 #4]  INFO -- : [2c5ed467-5129-4e52-9794-c22a611efaec] Started GET "/assets/logo_altran.png" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:00.480539+00:00 heroku[router]: at=info method=GET path="/assets/single_folio/featured1.jpg" host=mysterious-crag-68857.herokuapp.com request_id=62f2a2a3-392b-446d-be9b-a32e38f68397 fwd="80.12.27.252" dyno=web.1 connect=1ms service=19ms status=200 bytes=230727 protocol=https
2017-11-16T16:08:00.628238+00:00 heroku[router]: at=info method=GET path="/assets/home/build.jpg" host=mysterious-crag-68857.herokuapp.com request_id=f9d88aa4-d176-4190-8ad7-08f15cffc6fd fwd="80.12.27.252" dyno=web.1 connect=0ms service=7ms status=200 bytes=19242 protocol=https
2017-11-16T16:08:00.584670+00:00 heroku[router]: at=info method=GET path="/assets/logo_altran.png" host=mysterious-crag-68857.herokuapp.com request_id=2c5ed467-5129-4e52-9794-c22a611efaec fwd="80.12.27.252" dyno=web.1 connect=0ms service=4ms status=200 bytes=8918 protocol=https
2017-11-16T16:08:00.623571+00:00 app[web.1]: I, [2017-11-16T16:08:00.623424 #4]  INFO -- : [f9d88aa4-d176-4190-8ad7-08f15cffc6fd] Started GET "/assets/home/build.jpg" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:01.911423+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=mysterious-crag-68857.herokuapp.com request_id=69791277-1eb3-4067-a23a-51987305595b fwd="80.12.27.252" dyno=web.1 connect=1ms service=1ms status=200 bytes=180 protocol=https
2017-11-16T16:08:04.306986+00:00 heroku[router]: at=info method=GET path="/assets/application-cbd352f84234371962220aac536e7439e570099d31857c088b4e6d82141e9206.css" host=mysterious-crag-68857.herokuapp.com request_id=9d090e84-2bfe-49d8-afe1-7a5769d84497 fwd="80.12.27.252" dyno=web.1 connect=1ms service=5ms status=304 bytes=48 protocol=https
2017-11-16T16:12:50.000000+00:00 app[api]: Build started by user benchoufi.mehdi@gmail.com
2017-11-16T16:13:08.103929+00:00 heroku[web.1]: Restarting
2017-11-16T16:13:08.116568+00:00 heroku[web.1]: State changed from up to starting
2017-11-16T16:13:07.390096+00:00 app[api]: Release v7 created by user benchoufi.mehdi@gmail.com
2017-11-16T16:13:07.390096+00:00 app[api]: Deploy 99038abe by user benchoufi.mehdi@gmail.com
2017-11-16T16:12:50.000000+00:00 app[api]: Build succeeded
2017-11-16T16:13:08.751218+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-11-16T16:13:08.761369+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2017-11-16T16:13:08.788899+00:00 app[web.1]: Exiting
2017-11-16T16:13:08.789433+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/puma-3.10.0/lib/puma/server.rb:395:in `close': stream closed (IOError)
2017-11-16T16:13:08.789487+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.4.0/gems/puma-3.10.0/lib/puma/server.rb:398:in `handle_servers'
2017-11-16T16:13:08.789453+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.4.0/gems/puma-3.10.0/lib/puma/server.rb:395:in `ensure in handle_servers'
2017-11-16T16:13:08.789489+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.4.0/gems/puma-3.10.0/lib/puma/server.rb:327:in `block in run'
2017-11-16T16:13:08.907475+00:00 heroku[web.1]: Process exited with status 1
2017-11-16T16:13:13.745852+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 5997 -e production`
2017-11-16T16:13:22.652430+00:00 heroku[web.1]: State changed from starting to up
2017-11-16T16:13:22.424108+00:00 app[web.1]: => Booting Puma
2017-11-16T16:13:22.424142+00:00 app[web.1]: => Rails 5.0.6 application starting in production on http://0.0.0.0:5997
2017-11-16T16:13:22.424145+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-11-16T16:13:22.424195+00:00 app[web.1]: Puma starting in single mode...
2017-11-16T16:13:22.424286+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-11-16T16:13:22.424247+00:00 app[web.1]: * Version 3.10.0 (ruby 2.4.1-p111), codename: Russell's Teapot
2017-11-16T16:13:22.424352+00:00 app[web.1]: * Environment: production
2017-11-16T16:13:22.424528+00:00 app[web.1]: * Listening on tcp://0.0.0.0:5997
2017-11-16T16:13:22.425055+00:00 app[web.1]: Use Ctrl-C to stop
2017-11-16T16:13:57.966340+00:00 app[web.1]: I, [2017-11-16T16:13:57.966187 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936] Started GET "/" for 80.12.27.252 at 2017-11-16 16:13:57 +0000
2017-11-16T16:13:58.001708+00:00 app[web.1]: I, [2017-11-16T16:13:58.001639 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936]   Rendered pages/index.html.erb within layouts/application (0.9ms)
2017-11-16T16:13:57.996269+00:00 app[web.1]: I, [2017-11-16T16:13:57.996152 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936] Processing by PagesController#index as HTML
2017-11-16T16:13:58.000897+00:00 app[web.1]: I, [2017-11-16T16:13:58.000568 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936]   Rendering pages/index.html.erb within layouts/application
2017-11-16T16:13:58.296994+00:00 app[web.1]: I, [2017-11-16T16:13:58.296906 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936] Completed 200 OK in 301ms (Views: 299.3ms)
2017-11-16T16:13:58.286219+00:00 app[web.1]: I, [2017-11-16T16:13:58.286073 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936]   Rendered layouts/_nav.html.erb (0.7ms)
2017-11-16T16:13:58.296500+00:00 app[web.1]: I, [2017-11-16T16:13:58.296376 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936]   Rendered layouts/_footer.html.erb (9.3ms)
2017-11-16T16:13:58.290239+00:00 heroku[router]: at=info method=GET path="/" host=mysterious-crag-68857.herokuapp.com request_id=e8dd584a-d608-4421-ac81-44cd455ed936 fwd="80.12.27.252" dyno=web.1 connect=0ms service=348ms status=200 bytes=14894 protocol=https
2017-11-16T16:13:58.571091+00:00 heroku[router]: at=info method=GET path="/assets/application-cbd352f84234371962220aac536e7439e570099d31857c088b4e6d82141e9206.css" host=mysterious-crag-68857.herokuapp.com request_id=92a4edc0-7f6f-4317-b7b8-7ea7e202aff4 fwd="80.12.27.252" dyno=web.1 connect=0ms service=4ms status=200 bytes=290 protocol=https
2017-11-16T16:13:58.704480+00:00 heroku[router]: at=info method=GET path="/assets/application-7a19b05aebcc1264ba7bc75e8a9ab79af4669370f312952095c90b8160480841.js" host=mysterious-crag-68857.herokuapp.com request_id=db83d660-cedf-4642-972c-1d2b4e08d156 fwd="80.12.27.252" dyno=web.1 connect=0ms service=3ms status=200 bytes=303 protocol=https
2017-11-16T16:13:58.832979+00:00 heroku[router]: at=info method=GET path="/assets/logo2.png" host=mysterious-crag-68857.herokuapp.com request_id=16ea7daf-d704-43f0-a8ce-91243a15b8f3 fwd="80.12.27.252" dyno=web.1 connect=0ms service=26ms status=200 bytes=15746 protocol=https
2017-11-16T16:13:58.817763+00:00 app[web.1]: I, [2017-11-16T16:13:58.817635 #4]  INFO -- : [16ea7daf-d704-43f0-a8ce-91243a15b8f3] Started GET "/assets/logo2.png" for 80.12.27.252 at 2017-11-16 16:13:58 +0000
2017-11-16T16:13:59.035120+00:00 app[web.1]: I, [2017-11-16T16:13:59.035020 #4]  INFO -- : [7191af72-e7a6-4c9f-b34d-f866349e19fe] Started GET "/assets/single_folio/featured1.jpg" for 80.12.27.252 at 2017-11-16 16:13:59 +0000
2017-11-16T16:13:59.038959+00:00 heroku[router]: at=info method=GET path="/assets/single_folio/featured1.jpg" host=mysterious-crag-68857.herokuapp.com request_id=7191af72-e7a6-4c9f-b34d-f866349e19fe fwd="80.12.27.252" dyno=web.1 connect=0ms service=18ms status=200 bytes=230727 protocol=https
2017-11-16T16:13:59.146207+00:00 heroku[router]: at=info method=GET path="/assets/fondation_pierre_fabre.png" host=mysterious-crag-68857.herokuapp.com request_id=f54b3701-44ae-4d9c-b76a-200a5be5f4f7 fwd="80.12.27.252" dyno=web.1 connect=0ms service=18ms status=200 bytes=3889 protocol=https
2017-11-16T16:13:59.137862+00:00 app[web.1]: I, [2017-11-16T16:13:59.137756 #4]  INFO -- : [b5620bf1-cd26-430e-bdc4-4b18d283d602] Started GET "/assets/logo_altran.png" for 80.12.27.252 at 2017-11-16 16:13:59 +0000
2017-11-16T16:13:59.152893+00:00 app[web.1]: I, [2017-11-16T16:13:59.152788 #4]  INFO -- : [f54b3701-44ae-4d9c-b76a-200a5be5f4f7] Started GET "/assets/fondation_pierre_fabre.png" for 80.12.27.252 at 2017-11-16 16:13:59 +0000
2017-11-16T16:13:59.158096+00:00 app[web.1]: I, [2017-11-16T16:13:59.158011 #4]  INFO -- : [19624a74-80a0-4796-b349-47e1a359291a] Started GET "/assets/home/build.jpg" for 80.12.27.252 at 2017-11-16 16:13:59 +0000
2017-11-16T16:13:59.161169+00:00 heroku[router]: at=info method=GET path="/assets/logo_altran.png" host=mysterious-crag-68857.herokuapp.com request_id=b5620bf1-cd26-430e-bdc4-4b18d283d602 fwd="80.12.27.252" dyno=web.1 connect=0ms service=34ms status=200 bytes=8918 protocol=https
2017-11-16T16:13:59.176271+00:00 heroku[router]: at=info method=GET path="/assets/home/build.jpg" host=mysterious-crag-68857.herokuapp.com request_id=19624a74-80a0-4796-b349-47e1a359291a fwd="80.12.27.252" dyno=web.1 connect=0ms service=43ms status=200 bytes=19242 protocol=https
2017-11-16T16:14:00.250138+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=mysterious-crag-68857.herokuapp.com request_id=8f82cf74-f19c-4fd8-af88-aaa76fba7f60 fwd="80.12.27.252" dyno=web.1 connect=0ms service=4ms status=200 bytes=180 protocol=https
2017-11-16T16:38:30.000000+00:00 app[api]: Build started by user benchoufi.mehdi@gmail.com
2017-11-16T16:38:47.990291+00:00 app[api]: Deploy 504623ba by user benchoufi.mehdi@gmail.com
2017-11-16T16:38:47.990291+00:00 app[api]: Release v8 created by user benchoufi.mehdi@gmail.com
2017-11-16T16:38:30.000000+00:00 app[api]: Build succeeded
2017-11-16T16:38:49.057909+00:00 heroku[web.1]: State changed from up to starting
2017-11-16T16:38:49.057351+00:00 heroku[web.1]: Restarting
2017-11-16T16:38:50.018531+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2017-11-16T16:38:50.030701+00:00 app[web.1]: === puma shutdown: 2017-11-16 16:38:50 +0000 ===
2017-11-16T16:38:50.030736+00:00 app[web.1]: - Goodbye!
2017-11-16T16:38:50.030914+00:00 app[web.1]: Exiting
2017-11-16T16:38:50.172254+00:00 heroku[web.1]: Process exited with status 143
2017-11-16T16:38:50.003821+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-11-16T16:38:52.617190+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 3626 -e production`
2017-11-16T16:38:56.842223+00:00 app[web.1]: => Booting Puma
2017-11-16T16:38:56.842258+00:00 app[web.1]: => Rails 5.0.6 application starting in production on http://0.0.0.0:3626
2017-11-16T16:38:56.842260+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-11-16T16:38:56.842261+00:00 app[web.1]: Puma starting in single mode...
2017-11-16T16:38:56.842261+00:00 app[web.1]: * Version 3.10.0 (ruby 2.4.1-p111), codename: Russell's Teapot
2017-11-16T16:38:56.842267+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-11-16T16:38:56.842268+00:00 app[web.1]: * Environment: production
2017-11-16T16:38:56.842314+00:00 app[web.1]: * Listening on tcp://0.0.0.0:3626
2017-11-16T16:38:56.842706+00:00 app[web.1]: Use Ctrl-C to stop
2017-11-16T16:38:56.991984+00:00 heroku[web.1]: State changed from starting to up

此外,这里是application.css.scss

的内容
*= require animate
*= require jquery-ui
*= require owl.carousel
*= require owl.theme
*= require magnific-popup
*= require_self
*= require_tree .
*/
@import "bootstrap";
@import "bootstrap-sprockets";
@import "font-awesome";

3 个答案:

答案 0 :(得分:0)

是否可以更准确地了解发生的事情,也许您可​​以分享您的heroku日志。

Type =&gt; heroku日志 - 终端上的尾巴

由于

答案 1 :(得分:0)

当您在heroku上运行应用时,您需要预编译资产

执行以下操作: 在development.rb文件中输入以下行:

  

config.assets.debug = false

然后运行

RAILS_ENV=production bundle exec rake assets:precompile

答案 2 :(得分:0)

您需要配置Rails以在生产中提供静态资产:config / environments / production.rb

config.assets.compile = true

试着希望得到它的帮助!