Rails 4 + Devise + Heroku

Вопрос:

im пытается развернуть мое приложение в Heroku. Я использую Rails 4, последний Devise (попробовал как 3.0.0.rc и репо) и ruby 1.9.3 (также попробовал 2.0). Я не могу пройти мимо первоначального толчка, похоже, что героку не видит придумать. Локальные 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 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

Мой Gemfile:

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

Лучший ответ:

попробуй это

rails generate devise:install

Ответ №1

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

Это объект трубопровода активов, а не Rails4 или Devise.

Ответ №2

Я не думаю, что драгоценный камень может помочь. Я не использую его сам, и я не сталкивался с этой конкретной проблемой. Heroku также обескураживает использование драгоценного камня сейчас, поскольку он использует много памяти. Вместо этого они используют узел для компиляции активов. (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 говорит, что это необходимо для разработки с Rails 3.1 на Heroku. Я знаю, что вы на Rails 4, так что это может не помочь — но кажется, стоит попробовать, если создание базы данных сначала не сработает.

Ответ №3

Вы не установили драгоценный камень в вас Gemfile.

Ответ №4

У меня не было этой проблемы, но моя настройка выглядит как этот gemfile

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

в enivronment (c9) Я запускаю эту установку пакета — -without production В другом приложении, над которым я работал, я импортировал Postgress, чтобы избежать возможных ошибок между средами разработки и производства

Оцените статью
TechArks.Ru
Добавить комментарий