rails3.1.0.rc5 + backbone.js部署到heroku的问题

时间:2011-08-15 13:59:18

标签: ruby-on-rails-3.1

我使用rails 3.1.0.rc5和backbone.js我在heroku上部署rails应用程序时遇到问题,虽然在我的本地主机上一切正常。我将应用程序推送到Hiroko并迁移了数据库,我收到了这些错误:( log heroku)

Started GET "/providers" for 217.147.160.139 at 2011-08-15 05:20:57 -0700   
2011-08-15T12:20:57+00:00 app[web.1]:   Processing by ProvidersController#index as HTML
2011-08-15T12:20:57+00:00 app[web.1]: Rendered providers/index.html.erb within
layouts/application (0.4ms)
2011-08-15T12:20:57+00:00 app[web.1]: Completed 500 Internal Server Error in 3ms
2011-08-15T12:20:57+00:00 app[web.1]: 
2011-08-15T12:20:57+00:00 app[web.1]: ActionView::Template::Error (Not a directory -
/app/app/assets/application.js):
2011-08-15T12:20:57+00:00 app[web.1]:     2: <html>
2011-08-15T12:20:57+00:00 app[web.1]:     3: <head>
2011-08-15T12:20:57+00:00 app[web.1]:     4:   <title>Providers</title>
2011-08-15T12:20:57+00:00 app[web.1]:     5:   <%= stylesheet_link_tag    "application",     
"sw_on_backbone" %>
2011-08-15T12:20:57+00:00 app[web.1]:     6:   <%= javascript_include_tag "application",   
"backbone/sw_on_bckb" %>
2011-08-15T12:20:57+00:00 app[web.1]:     7:   <%= csrf_meta_tags %>
2011-08-15T12:20:57+00:00 app[web.1]:     8: </head>
2011-08-15T12:20:57+00:00 app[web.1]:   app/views/layouts/application.html.erb:5:in    
"_app_views_layouts_application_html_erb___1529301457241305386_13879700"
2011-08-15T12:20:57+00:00 app[web.1]:   app/controllers/providers_controller.rb:7:in `index'
2011-08-15T12:20:57+00:00 app[web.1]: 
2011-08-15T12:20:57+00:00 app[web.1]: 
2011-08-15T12:20:57+00:00 app[web.1]: cache: [GET /providers] miss

我的Gemfile:

2 gem "rails-backbone"
3 gem 'execjs'
4 gem 'therubyracer'
5 gem 'rails', '3.1.0.rc5'
6 gem 'arel','2.1.4'
7 gem 'rake', '0.9.2'
8 gem 'heroku'
9 gem 'pg'
10 gem 'sprockets'
11 # Bundle edge Rails instead:
12 # gem 'rails',     :git => 'git://github.com/rails/rails.git'
13 gem 'sqlite3'
14 
15 # Asset template engines
16 gem 'sass-rails'
17 gem 'coffee-script'
18 gem 'uglifier'
19 
20 gem 'jquery-rails'
21 
22 # Use unicorn as the web server
23 # gem 'unicorn'
24 
25 # Deploy with Capistrano
26 # gem 'capistrano'
27 
28 # To use debugger
29 # gem 'ruby-debug19', :require => 'ruby-debug'
30 
31 group :test do
32   # Pretty printed test output
33   gem 'turn', :require => false
34 end

虽然我使用的是最新版本(sprockets(2.0.0.beta.13)),但我认为问题是sprotskets已被破坏。

$ gem list
actionmailer (3.1.0.rc5, 3.1.0.rc4)
actionpack (3.1.0.rc5, 3.1.0.rc4)
activemodel (3.1.0.rc5, 3.1.0.rc4)
activerecord (3.1.0.rc5, 3.1.0.rc4) 
activeresource (3.1.0.rc5, 3.1.0.rc4)
activesupport (3.1.0.rc5, 3.1.0.rc4)
addressable (2.2.6)
ansi (1.3.0)
arel (2.1.5, 2.1.4, 2.1.3)
bcrypt-ruby (2.1.4)
builder (3.0.0)
bundler (1.0.15)
chunky_png (1.2.1)
coffee-rails (3.1.0.rc.5)
coffee-script (2.2.0)
coffee-script-source (1.1.2, 1.1.1)
compass (0.11.5)
ejs (1.0.0)
erubis (2.7.0)
execjs (1.2.4, 1.2.0)
fssm (0.2.7)
heroku (2.4.1, 2.3.6)
hike (1.2.0, 1.1.0)
i18n (0.6.0)
jquery-rails (1.0.13, 1.0.12)
launchy (2.0.5, 2.0.3)
libv8 (3.3.10.2 x86-linux)
mail (2.3.0)
mime-types (1.16)
multi_json (1.0.3)
open4 (1.1.0)
pg (0.11.0)
Platform (0.4.0)
polyglot (0.3.2, 0.3.1)
POpen4 (0.1.4)
postgres-pr (0.6.3)
rack (1.3.2, 1.3.1, 1.3.0)
rack-cache (1.0.2)
rack-mount (0.8.2, 0.8.1)
rack-ssl (1.3.2)
rack-test (0.6.1, 0.6.0)
rails (3.1.0.rc5)
rails-backbone (0.5.3, 0.5.2, 0.5.1, 0.2.0 )
railties (3.1.0.rc5, 3.1.0.rc4)
rake (0.9.2, 0.8.7)
rdoc (3.9.2, 3.9.1, 3.8)
rest-client (1.6.3)
sass (3.1.7, 3.1.5, 3.1.4)
sass-rails (3.1.0.rc.5, 3.1.0.rc.4)
sprockets (2.0.0.beta.13)
sqlite3 (1.3.4, 1.3.3)
term-ansicolor (1.0.6, 1.0.5)
therubyracer (0.9.3, 0.9.2)
thor (0.14.6)
tilt (1.3.2)
treetop (1.4.10, 1.4.9)
turn (0.8.2)
tzinfo (0.3.29)
uglifier (1.0.0)
yui-compressor (0.9.6)

stylesheet_link_tag和javascript_include_tag的路径已损坏(/app/app/assets/application.js)(在日志heroku中)。 谢谢你的帮助。

2 个答案:

答案 0 :(得分:0)

可能是问题,你的application.js的路径是错的? app / app / assets app app / assets

我的设置与您几乎相似,并且对于therubyracer有不良体验。 你可以像那样摆脱他:https://stackoverflow.com/questions/7150498/ruby-on-rails-3-1-rc5-with-cedar-stack-on-heroku-and-without-therubyracer

答案 1 :(得分:0)

预编译资产为我解决了这个问题。为此,请运行以下命令:

bundle exec rake assets:precompile

这将创建文件夹public / assets,它将包含所有预编译资产。将所有生成的文件推送到Heroku。

此外,Heroku要求在config / application.rb文件中将config.assets.initialize_on_precompile设置为false。

要了解有关在Rails中预编译资产的更多信息,请参阅此处: http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets