我有一个现有的heroku rails 4应用程序(
https://applicantlabs.herokuapp.com/)在本地运行时看起来是正确的,但是当我在heroku上运行时,造型是破碎的。
我的gemfile看起来像这样
@H_403_4@source 'https://rubygems.org' ruby "2.2.1" gem 'rails','4.2.1' gem 'pg' gem 'uglifier','>= 1.3.0' gem 'jquery-rails' gem 'devise' gem 'devise-bootstrap-views' gem "twitter-bootstrap-rails" gem 'rails_12factor',group: :production # for heroku gem 'puma' gem 'sucker_punch'我试图通过将这个添加到config / environments / production.rb文件然后部署来解决这个问题
@H_403_4@config.assets.compile = true我也试过
@H_403_4@bundle exec rake assets:precompile然后提交并推送。
没有任何工作。
css文件被添加到app / assets / stylesheets中
然后在app / assets / stylesheets / application.css我有
@H_403_4@/* *= require animate.min *= require bootstrap_and_overrides *= require font-awesome *= require_self */ body{padding:0;margin:0;font-family:'Open Sans','Trebuchet MS',arial,sans-serif;font-size:13px}当我查看页面的源码并单击css文件时,它将填充奇怪的文本。这里有一点点:
@H_403_4@book����mark����8���8���ìS���当我推到heroku的输出是:
@H_403_4@~/Source/applicantlabs> git push heroku master Counting objects: 5,done. Delta compression using up to 4 threads. Compressing objects: 100% (5/5),done. Writing objects: 100% (5/5),483 bytes | 0 bytes/s,done. Total 5 (delta 3),reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Ruby app detected remote: -----> Compiling Ruby/Rails remote: -----> Using Ruby version: ruby-2.2.1 remote: -----> Installing dependencies using 1.7.12 remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment remote: Using rake 10.4.2 remote: Using minitest 5.6.1 remote: Using thread_safe 0.3.5 remote: Using builder 3.2.2 remote: Using erubis 2.7.0 remote: Using mini_portile 0.6.2 remote: Using rack 1.6.0 remote: Using mime-types 2.5 remote: Using arel 6.0.0 remote: Using bcrypt 3.1.10 remote: Using hitimes 1.2.2 remote: Using json 1.8.2 remote: Using orm_adapter 0.5.0 remote: Using thor 0.19.1 remote: Using devise-bootstrap-views 0.0.4 remote: Using execjs 2.5.2 remote: Using pg 0.18.1 remote: Using bundler 1.7.12 remote: Using rails_serve_static_assets 0.0.4 remote: Using rails_stdout_logging 0.0.3 remote: Using nokogiri 1.6.6.2 remote: Using rack-test 0.6.3 remote: Using warden 1.2.3 remote: Using puma 2.11.2 remote: Using sprockets 3.0.3 remote: Using tzinfo 1.2.2 remote: Using mail 2.6.3 remote: Using uglifier 2.7.1 remote: Using rails_12factor 0.0.3 remote: Using loofah 2.0.1 remote: Using i18n 0.7.0 remote: Using rails-html-sanitizer 1.0.2 remote: Using timers 4.0.1 remote: Using celluloid 0.16.0 remote: Using sucker_punch 1.4.0 remote: Using activesupport 4.2.1 remote: Using rails-deprecated_sanitizer 1.0.3 remote: Using activemodel 4.2.1 remote: Using rails-dom-testing 1.0.6 remote: Using activerecord 4.2.1 remote: Using actionview 4.2.1 remote: Using globalid 0.3.5 remote: Using actionpack 4.2.1 remote: Using activejob 4.2.1 remote: Using sprockets-rails 2.2.4 remote: Using railties 4.2.1 remote: Using jquery-rails 4.0.3 remote: Using responders 2.1.0 remote: Using actionmailer 4.2.1 remote: Using rails 4.2.1 remote: Using devise 3.4.1 remote: Using twitter-bootstrap-rails 3.2.0 remote: Your bundle is complete! remote: Gems in the groups development and test were not installed. remote: It was installed into ./vendor/bundle remote: Bundle completed (0.76s) remote: Cleaning up the bundler cache. remote: Detected manifest file,assuming assets were compiled locally remote: remote: -----> Discovering process types remote: Procfile declares types -> web remote: Default types for Ruby -> console,rake,worker remote: remote: -----> Compressing... done,67.4MB remote: -----> Launching... done,v38 remote: https://applicantlabs.herokuapp.com/ deployed to Heroku remote: remote: Verifying deploy... done. To https://git.heroku.com/applicantlabs.git 697fef0..4cc4ec5 master -> master如果我跑
@H_403_4@bundle exec rake assets:precompile RAILS_ENV=production输出是
@H_403_4@bundle exec rake assets:precompile RAILS_ENV=production --trace ** Invoke assets:precompile (first_time) ** Invoke assets:environment (first_time) ** Execute assets:environment ** Invoke environment (first_time) ** Execute environment rake aborted! ActiveRecord::AdapterNotSpecified: database configuration does not specify adapter /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activerecord-4.2.1/lib/active_record/connection_adapters/connection_specification.rb:171:in `spec' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activerecord-4.2.1/lib/active_record/connection_handling.rb:50:in `establish_connection' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activerecord-4.2.1/lib/active_record/railtie.rb:120:in `block (2 levels) in <class:Railtie>' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activesupport-4.2.1/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activesupport-4.2.1/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activesupport-4.2.1/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activesupport-4.2.1/lib/active_support/lazy_load_hooks.rb:44:in `each' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activesupport-4.2.1/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activerecord-4.2.1/lib/active_record/base.rb:316:in `<module:ActiveRecord>' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activerecord-4.2.1/lib/active_record/base.rb:26:in `<top (required)>' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1/gems/devise-3.4.1/lib/devise/orm/active_record.rb:3:in `<top (required)>' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `block in require' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require' /Users/grantspilsbury/Source/applicantlabs/config/initializers/devise.rb:22:in `block in <top (required)>' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1/gems/devise-3.4.1/lib/devise.rb:293:in `setup' /Users/grantspilsbury/Source/applicantlabs/config/initializers/devise.rb:3:in `<top (required)>' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `block in load' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/railties-4.2.1/lib/rails/engine.rb:652:in `block in load_config_initializer' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activesupport-4.2.1/lib/active_support/notifications.rb:166:in `instrument' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/railties-4.2.1/lib/rails/engine.rb:651:in `load_config_initializer' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/railties-4.2.1/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/railties-4.2.1/lib/rails/engine.rb:615:in `each' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/railties-4.2.1/lib/rails/engine.rb:615:in `block in <class:Engine>' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/railties-4.2.1/lib/rails/initializable.rb:30:in `instance_exec' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/railties-4.2.1/lib/rails/initializable.rb:30:in `run' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/railties-4.2.1/lib/rails/initializable.rb:55:in `block in run_initializers' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:420:in `block (2 levels) in each_strongly_connected_component_from' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:419:in `block in each_strongly_connected_component_from' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/railties-4.2.1/lib/rails/initializable.rb:44:in `each' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/railties-4.2.1/lib/rails/initializable.rb:44:in `tsort_each_child' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:413:in `call' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:413:in `each_strongly_connected_component_from' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `each' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `call' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/railties-4.2.1/lib/rails/initializable.rb:54:in `run_initializers' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/railties-4.2.1/lib/rails/application.rb:352:in `initialize!' /Users/grantspilsbury/Source/applicantlabs/config/environment.rb:5:in `<top (required)>' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `block in require' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/railties-4.2.1/lib/rails/application.rb:328:in `require_environment!' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/railties-4.2.1/lib/rails/application.rb:457:in `block in run_tasks_blocks' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `call' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `each' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `execute' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:165:in `invoke' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1@global/gems/sprockets-rails-2.2.4/lib/sprockets/rails/task.rb:64:in `block (2 levels) in define' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `call' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `each' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `execute' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:201:in `block in invoke_prerequisites' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:199:in `each' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:199:in `invoke_prerequisites' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:178:in `block in invoke_with_call_chain' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:165:in `invoke' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `each' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:100:in `top_level' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:78:in `block in run' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:75:in `run' /Users/grantspilsbury/.rvm/rubies/ruby-2.2.1/bin/rake:33:in `<main>' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval' /Users/grantspilsbury/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>' Tasks: TOP => environment解决方法
根据我可以看到的,你有一些问题要解决,因为你的问题涉及到CSS我会去那里:
@H_403_4@Mixed Content: The page at 'https://applicantlabs.herokuapp.com/' was loaded over HTTPS,but requested an insecure resource 'http://player.vimeo.com/video/57175742?title=0&byline=0&portrait=0&color=e2007a'. This request has been blocked; the content must be served over HTTPS.
applicantlabs.herokuapp.com/:401
Mixed Content: The page at 'https://applicantlabs.herokuapp.com/' was loaded over HTTPS,but requested an insecure resource 'http://www.youtube.com/embed/ySJhFCtVTUQ?list=UUvNBXWGykQrWb7kPAn5eLUQ'. This request has been blocked; the content must be served over HTTPS.
application-4ed64624ca6f0911d127cb1a8d49f3c36aedeffcb9f0216df950229bb9db906c.js:13549
Uncaught TypeError: Cannot read property 'defaults' of undefined
application-4ed64624ca6f0911d127cb1a8d49f3c36aedeffcb9f0216df950229bb9db906c.js:13496
Uncaught TypeError: Cannot read property 'layoutColors' of undefined application-4ed64624ca6f0911d127cb1a8d49f3c36aedeffcb9f0216df950229bb9db906c.js:13496
@H_403_4@colors: mvpready_core.layoutColors
这也标记为未定义
@H_403_4@$.extend( true,DataTable.defaults,{...您编译的CSS资源未正确构造,数据看起来损坏。文件名是welcome-xxx.css,而不是标准应用程序-xxxx.css,它也填满了损坏的数据,而不是CSS。这是你的CSS:
@H_403_4@bookmark88�S`�^�,^��A�SApplicationsMAMPhtdocsmvp-release-2.0.1 mvp-themebower_componentsanimate.cssanimate.min.css $0@\p��)�'7�����l� m�Xm��n� o� ���,<LA�ŕ� file:///���������EE����������E6OXdknnkdXO6ic11o�PNG现在,我将要求下一步调试此CSS问题是要求您运行:
@H_403_4@$bundle exec rake assets:precompile RAILS_ENV=production