0

我试图将我的应用程序部署到 Heroku。我正在使用 Rails 4、最新的 Devise(3.0.0.rc在 repo 中都试过)和 ruby​​ 1.9.3(也试过 2.0)。我无法通过最初的推动,似乎 heroku 没有看到设计。本地assets:precompile任务运行没有问题。这是输出:

git push heroku master                                                                                                                                      -----> Ruby/Rails app detected
-----> Using Ruby version: ruby-1.9.3
-----> Installing dependencies using Bundler version 1.3.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
       Fetching gem metadata from https://rubygems.org/..........
       Fetching gem metadata from https://rubygems.org/..
       Installing rake (10.1.0)
       Installing i18n (0.6.4)
       Installing minitest (4.7.5)
       Installing multi_json (1.7.7)
       Installing atomic (1.1.10)
       Installing thread_safe (0.1.0)
       Installing tzinfo (0.3.37)
       Installing activesupport (4.0.0)
       Installing builder (3.1.4)
       Installing erubis (2.7.0)
       Installing rack (1.5.2)
       Installing rack-test (0.6.2)
       Installing actionpack (4.0.0)
       Installing mime-types (1.23)
       Installing polyglot (0.3.3)
       Installing treetop (1.4.14)
       Installing mail (2.5.4)
       Installing actionmailer (4.0.0)
       Installing activemodel (4.0.0)
       Installing activerecord-deprecated_finders (1.0.3)
       Installing arel (4.0.0)
       Installing activerecord (4.0.0)
       Installing bcrypt-ruby (3.0.1)
       Installing coffee-script-source (1.6.3)
       Installing execjs (1.4.0)
       Installing coffee-script (2.2.0)
       Installing thor (0.18.1)
       Installing railties (4.0.0)
       Installing coffee-rails (4.0.0)
       Installing orm_adapter (0.4.0)
       Installing warden (1.2.1)
       Installing devise (3.0.0.rc)
       Installing tilt (1.4.1)
       Installing haml (4.0.3)
       Installing haml-rails (0.4)
       Installing hike (1.2.3)
       Installing jbuilder (1.4.2)
       Installing jquery-rails (3.0.2)
       Installing json (1.8.0)
       Installing mysql2 (0.3.11)
       Installing nested_form (0.3.2)
       Installing pg (0.15.1)
       Using bundler (1.3.2)
       Installing sprockets (2.10.0)
       Installing sprockets-rails (2.0.0)
       Installing rails (4.0.0)
       Installing rails_serve_static_assets (0.0.1)
       Installing rails_stdout_logging (0.0.1)
       Installing rails_12factor (0.0.2)
       Installing rdoc (3.12.2)
       Installing sass (3.2.9)
       Installing sass-rails (4.0.0)
       Installing sdoc (0.3.20)
       Installing simple_form (1.4.1)
       Installing turbolinks (1.2.0)
       Installing twitter-bootstrap-rails (2.2.7)
       Installing uglifier (2.1.1)
       Your bundle is complete! It was installed into ./vendor/bundle
       Post-install message from haml:
       HEADS UP! Haml 4.0 has many improvements, but also has changes that may break
       your application:
       * Support for Ruby 1.8.6 dropped
       * Support for Rails 2 dropped
       * Sass filter now always outputs <style> tags
       * Data attributes are now hyphenated, not underscored
       * html2haml utility moved to the html2haml gem
       * Textile and Maruku filters moved to the haml-contrib gem
       For more info see:
       http://rubydoc.info/github/haml/haml/file/CHANGELOG.md
       Post-install message from rdoc:
       Depending on your version of ruby, you may need to install ruby rdoc/ri data:
       <= 1.8.6 : unsupported
       = 1.8.7 : gem install rdoc-data; rdoc-data --install
       = 1.9.1 : gem install rdoc-data; rdoc-data --install
       >= 1.9.2 : nothing to do! Yay!
       Post-install message from twitter-bootstrap-rails:
       Important: You may need to add a javascript runtime to your Gemfile in order for bootstrap's LESS files to compile to CSS.
       **********************************************
       ExecJS supports these runtimes:
       therubyracer - Google V8 embedded within Ruby
       therubyrhino - Mozilla Rhino embedded within JRuby
       Node.js
       Apple JavaScriptCore - Included with Mac OS X
       Microsoft Windows Script Host (JScript)
       **********************************************
       Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       rake aborted!
       undefined method `devise' for #<Class:0x00000002962218>
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:22:in `method_missing'
       /tmp/build_238qt4r3vnes0/app/models/user.rb:5:in `<class:User>'
       /tmp/build_238qt4r3vnes0/app/models/user.rb:1:in `<top (required)>'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:329:in `require_or_load'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:462:in `load_missing_constant'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:183:in `const_missing'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:226:in `const_get'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:226:in `block in constantize'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:224:in `each'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:224:in `inject'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:224:in `constantize'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:534:in `get'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:565:in `constantize'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/devise-3.0.0.rc/lib/devise.rb:274:in `get'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/devise-3.0.0.rc/lib/devise/mapping.rb:77:in `to'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/devise-3.0.0.rc/lib/devise/mapping.rb:72:in `modules'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/devise-3.0.0.rc/lib/devise/mapping.rb:89:in `routes'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/devise-3.0.0.rc/lib/devise/mapping.rb:156:in `default_used_route'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/devise-3.0.0.rc/lib/devise/mapping.rb:66:in `initialize'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/devise-3.0.0.rc/lib/devise.rb:308:in `new'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/devise-3.0.0.rc/lib/devise.rb:308:in `add_mapping'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/devise-3.0.0.rc/lib/devise/rails/routes.rb:208:in `block in devise_for'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/devise-3.0.0.rc/lib/devise/rails/routes.rb:207:in `each'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/devise-3.0.0.rc/lib/devise/rails/routes.rb:207:in `devise_for'
       /tmp/build_238qt4r3vnes0/config/routes.rb:2:in `block in <top (required)>'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:316:in `instance_exec'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:316:in `eval_block'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:294:in `draw'
       /tmp/build_238qt4r3vnes0/config/routes.rb:1:in `<top (required)>'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `block in load'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:40:in `each'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:40:in `load_paths'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:16:in `reload!'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/railties-4.0.0/lib/rails/application.rb:102:in `reload_routes!'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/devise-3.0.0.rc/lib/devise/rails.rb:14:in `block in <class:Engine>'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:36:in `call'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:44:in `each'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/railties-4.0.0/lib/rails/application/finisher.rb:55:in `block in <module:Finisher>'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
       /tmp/build_238qt4r3vnes0/config/environment.rb:5:in `<top (required)>'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/railties-4.0.0/lib/rails/application.rb:189:in `require_environment!'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/railties-4.0.0/lib/rails/application.rb:249:in `block in run_tasks_blocks'
       /tmp/build_238qt4r3vnes0/vendor/bundle/ruby/1.9.1/gems/sprockets-rails-2.0.0/lib/sprockets/rails/task.rb:54:in `block (2 levels) in define'
       Tasks: TOP => environment
       (See full trace by running task with --trace)
 !
 !     Precompiling assets failed.
 !

 !     Push rejected, failed to compile Ruby/Rails app

我的宝石文件:

ruby '1.9.3'
source 'https://rubygems.org'


gem 'rails', '4.0.0'
gem 'mysql2'
gem 'simple_form'
gem 'twitter-bootstrap-rails'
gem 'haml-rails'
gem 'devise', "3.0.0rc"
gem 'nested_form'
gem 'rails_12factor'


gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'

group :doc do
  gem 'sdoc', require: false
end

group :production do
  gem 'pg'
end

group :development, :test do
 gem 'rspec-rails'
 gem 'capybara'
 gem 'factory_girl_rails'
 gem 'faker'
 gem 'guard-rspec'
 gem 'terminal-notifier-guard'
 gem 'quiet_assets'
end

group :development do
  gem 'thin'
end

group :test do
 gem 'database_cleaner'
 gem 'fuubar'
 gem 'shoulda'
end
4

5 回答 5

1

试试这个

rails generate devise:install
于 2013-07-05T16:04:13.077 回答
1

heroku labs:enable user-env-compile -a myapp

这是一个资产管道,而不是 Rails4 或 Devise。

于 2013-07-05T16:15:36.897 回答
1

我认为rubyracer gem 不会有帮助。我自己不使用它,也没有遇到这个特殊问题。Heroku 现在也不鼓励使用 gem,因为它会占用大量内存。他们使用 Node 来编译资产。(https://devcenter.heroku.com/articles/rails-asset-pipeline

在推送应用之前,您是否在 Heroku 上创建了数据库?此线程的讨论表明这可能会解决问题:https ://github.com/plataformatec/devise/issues/1339 。我一起工作的一位讲师还让他的学生在他们第一次推送他们的应用程序之前创建数据库。如果你需要它,命令是:

heroku addons:add heroku-postgresql.

如果这不起作用,另一种选择是设置:

config.assets.initialize_on_precompile = false

Devise 文档说这对于在 Heroku 上使用 Rails 3.1 进行设计是必要的。我知道您使用的是 Rails 4,所以这可能无济于事 - 但如果首先创建数据库不起作用,似乎值得一试。

于 2014-04-15T02:15:29.377 回答
0

您没有在 Gemfile 中安装 ruby​​racer 的 gem。

于 2013-07-08T10:44:14.957 回答
0

没有这个问题,但我的设置看起来像这个 gemfile

group :development, :test do
  gem 'sqlite3'
  ...

在环境(c9)中我运行这个捆绑安装——没有生产在我正在开发的另一个应用程序上我导入了 Postgress 以避免开发和生产环境之间的任何可能的错误

于 2016-03-11T00:31:11.720 回答