0

我有一个具有照片上传功能的 Rails 应用程序。以前我使用 CarrierWave_Direct 直接上传到 S3(基于Railscast 383)。为了优化应用程序,我继续切换到 Cloudinary。

该应用程序目前在本地与 Cloudinary 一起工作得很好。但是,当我推送到 heroku 时,应用程序因服务器日志错误而崩溃:

ActionView::Template::Error (Invalid CSS after "  font-family: ": expected expression (e.g. 1px, bold), was "@altFontFamily;"
2013-09-04T05:16:29.148898+00:00 app[web.1]:   (in /app/app/assets/stylesheets/application.css)):
2013-09-04T05:16:29.148898+00:00 app[web.1]:     12:       <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.1/html5shiv.js" type="text/javascript"></script>
2013-09-04T05:16:29.148898+00:00 app[web.1]:     13:     <![endif]-->
2013-09-04T05:16:29.148898+00:00 app[web.1]:     14: 
2013-09-04T05:16:29.148898+00:00 app[web.1]:     15:     <%= stylesheet_link_tag "application", :media => "all" %>
2013-09-04T05:16:29.148898+00:00 app[web.1]:     16: 
2013-09-04T05:16:29.148898+00:00 app[web.1]:     17:     <!-- For third-generation iPad with high-resolution Retina display: -->
2013-09-04T05:16:29.148898+00:00 app[web.1]:     18:     <!-- Size should be 144 x 144 pixels -->
2013-09-04T05:16:29.149145+00:00 app[web.1]:   app/views/layouts/application.html.erb:15:in `_app_views_layouts_application_html_erb__164934612574999860_69925614481940'
2013-09-04T05:16:29.149145+00:00 app[web.1]: 
2013-09-04T05:16:29.149145+00:00 app[web.1]: 
2013-09-04T05:16:29.149499+00:00 app[web.1]: Processing by LandingController#landing as HTML
2013-09-04T05:16:29.149499+00:00 app[web.1]:   Rendered landing/landing.html.erb within layouts/application (58.3ms)
2013-09-04T05:16:29.149499+00:00 app[web.1]: Completed 500 Internal Server Error in 158ms

我恢复到添加 Cloudinary 之前的先前提交(当应用程序工作时,并且已经隔离了应用程序开始中断的那一刻,当我添加 Cloudinary Gem 时。即使错误引用了 css 错误,应用程序也只会在我添加时中断Cloudinary 宝石。

在试图解决这个问题的过程中,我发现当我运行 heroku run rake 时出现错误。

耙中止!nil:NilClass 的未定义方法“[]”

我怀疑这是问题所在,但是该应用程序仅在添加 Cloudinary Gem 时才会中断,即使我在添加 gem 之前运行“heroku run rake”,我也会收到相同的错误,但该应用程序仍然可以运行。

这是我运行 heroku run rake --trace 时得到的结果

$ heroku run rake --trace
Running `rake --trace` attached to terminal... up, run.1893
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
** Invoke default (first_time)
** Invoke spec (first_time)
** Invoke test:prepare (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment 
** Invoke db:load_config 
** Execute db:test:purge
rake aborted!
undefined method `[]' for nil:NilClass
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/railties/databases.rake:511:in `block (3 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:197:in `block in invoke_prerequisites'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:195:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:195:in `invoke_prerequisites'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:174:in `block in invoke_with_call_chain'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/railties/databases.rake:544:in `block (3 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:197:in `block in invoke_prerequisites'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:195:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:195:in `invoke_prerequisites'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:174:in `block in invoke_with_call_chain'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:197:in `block in invoke_prerequisites'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:195:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:195:in `invoke_prerequisites'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:174:in `block in invoke_with_call_chain'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:197:in `block in invoke_prerequisites'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:195:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:195:in `invoke_prerequisites'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:174:in `block in invoke_with_call_chain'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/app/vendor/bundle/ruby/2.0.0/bin/rake:23:in `load'
/app/vendor/bundle/ruby/2.0.0/bin/rake:23:in `<main>'
Tasks: TOP => db:test:load => db:test:purge

任何建议都非常感谢。

编辑添加 application.css 文件。

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * 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 bootstrap_and_overrides
 *= require jquery.ui.datepicker
 *= require_tree .
 *= require jquery.ui.all
 */

 input[type=number]::-webkit-inner-spin-button,
 input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
 }
 .form-signin {
        max-width: 300px;
        padding: 19px 29px 29px;
        margin: 0 auto 20px;
        background-color: #fff;
        opacity: .9;
        border: 5px solid #0367b0;
        -webkit-border-radius: 5px;
           -moz-border-radius: 5px;
                border-radius: 5px;
        -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05);
           -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);
                box-shadow: 0 1px 2px rgba(0,0,0,.05);
                text-align: center;
      }
h2.form-signin {
  font-family: @altFontFamily;
}
.landing {
  background: url('baseball_dirt.jpg') no-repeat scroll center top transparent;
  height: 100%;
  padding:120px 0;
}
.signup {
  background: url('homeplate_line.jpg') no-repeat scroll center top transparent;
  height: 100%;
  padding:120px 0;
}
.signip .well {
  opacity: .85;
}
.signin {
  background: url('baseball_dirt.jpg') no-repeat scroll center top transparent;
  height: 100%;
  padding:120px 0;
}
.signin .well {
  opacity: .85;
}
4

1 回答 1

0

我终于找到了这个错误,它是无效的 css。

  font-family: 'Myriad W01 Lt It';
于 2013-11-10T10:32:04.867 回答