写真のアップロード機能を備えた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 エラーを参照していますが、追加したときにのみアプリが壊れます)。クラウディナリー ジェム。
これを理解しようとしている過程で、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
どんな提案でも大歓迎です。
EDIT 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;
}