Ruby on rails 设计不在Heroku平台上部署的gem
在花了2天的时间尝试在Heroku上部署我的Rails应用程序后,我决定放弃,并在这里寻求帮助 我的问题是,我正在尝试在Heroku平台上部署Rails 4.0.4应用程序(在我的本地环境中运行良好),但当我尝试在Heroku平台上部署时,它失败了。这就像Heroku没有识别Desive 3.2.4(或者它不兼容) 我总是得到同样的信息:Ruby on rails 设计不在Heroku平台上部署的gem,ruby-on-rails,ruby,heroku,ruby-on-rails-4,devise,Ruby On Rails,Ruby,Heroku,Ruby On Rails 4,Devise,在花了2天的时间尝试在Heroku上部署我的Rails应用程序后,我决定放弃,并在这里寻求帮助 我的问题是,我正在尝试在Heroku平台上部署Rails 4.0.4应用程序(在我的本地环境中运行良好),但当我尝试在Heroku平台上部署时,它失败了。这就像Heroku没有识别Desive 3.2.4(或者它不兼容) 我总是得到同样的信息: NoMethodError: undefined method `devise' for User (call 'User.connection' to es
NoMethodError: undefined method `devise' for User (call 'User.connection' to establish
a connection):Class
这是命令的输出git push heroku master
[jeffersonlsz@localhost showYourselfApp (master)]$ git push heroku master
Enter passphrase for key '/home/jeffersonlsz/.ssh/id_rsa':
X11 forwarding request failed on channel 0
Fetching repository, done.
Counting objects: 62, done.
Compressing objects: 100% (35/35), done.
Writing objects: 100% (36/36), 4.30 KiB, done.
Total 36 (delta 25), reused 0 (delta 0)
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using 1.5.2
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Fetching gem metadata from https://rubygems.org/..........
Fetching additional metadata from https://rubygems.org/..
Using i18n (0.6.9)
Using rake (10.3.1)
Using minitest (4.7.5)
Using multi_json (1.10.0)
Using thread_safe (0.3.3)
Using builder (3.1.4)
Using erubis (2.7.0)
Using tzinfo (0.3.39)
Using rack (1.5.2)
Using polyglot (0.3.4)
Using mime-types (1.25.1)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.2)
Using coffee-script-source (1.7.0)
Using sass (3.2.19)
Using execjs (2.0.2)
Using thor (0.19.1)
Using hike (1.2.3)
Using json (1.8.1)
Using pg (0.15.1)
Using bundler (1.5.2)
Using tilt (1.4.1)
Using rails_serve_static_assets (0.0.2)
Using rails_stdout_logging (0.0.3)
Using activesupport (4.0.4)
Using treetop (1.4.15)
Using rack-test (0.6.2)
Using coffee-script (2.2.0)
Using rdoc (4.1.1)
Using uglifier (2.5.0)
Using bootstrap-sass (2.3.2.0)
Using sprockets (2.11.0)
Using rails_12factor (0.0.2)
Using activemodel (4.0.4)
Using jbuilder (1.5.3)
Using actionpack (4.0.4)
Using mail (2.5.4)
Using sdoc (0.4.0)
Using activerecord (4.0.4)
Using railties (4.0.4)
Using sprockets-rails (2.0.1)
Using actionmailer (4.0.4)
Using coffee-rails (4.0.1)
Using jquery-rails (3.1.0)
Using sass-rails (4.0.3)
Using rails (4.0.4)
Using turbolinks (2.2.2)
Installing orm_adapter (0.5.0)
Installing warden (1.2.3)
Installing bcrypt (3.1.7)
Installing devise (3.2.4)
Your bundle is complete!
Gems in the groups development and test were not installed.
It was installed into ./vendor/bundle
Bundle completed (12.69s)
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!
NoMethodError: undefined method `devise' for User (call 'User.connection' to establish a connection):Class
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.4/lib/active_record/dynamic_matchers.rb:22:in `method_missing'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/app/models/user.rb:4:in `<class:User>'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/app/models/user.rb:1:in `<top (required)>'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `block in require'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:214:in `load_dependency'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:330:in `require_or_load'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:463:in `load_missing_constant'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:184:in `const_missing'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/inflector/methods.rb:226:in `const_get'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/inflector/methods.rb:226:in `block in constantize'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/inflector/methods.rb:224:in `each'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/inflector/methods.rb:224:in `inject'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/inflector/methods.rb:224:in `constantize'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:535:in `get'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:566:in `constantize'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/devise-3.2.4/lib/devise.rb:297:in `get'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/devise-3.2.4/lib/devise/mapping.rb:77:in `to'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/devise-3.2.4/lib/devise/mapping.rb:72:in `modules'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/devise-3.2.4/lib/devise/mapping.rb:89:in `routes'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/devise-3.2.4/lib/devise/mapping.rb:156:in `default_used_route'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/devise-3.2.4/lib/devise/mapping.rb:66:in `initialize'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/devise-3.2.4/lib/devise.rb:331:in `new'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/devise-3.2.4/lib/devise.rb:331:in `add_mapping'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/devise-3.2.4/lib/devise/rails/routes.rb:221:in `block in devise_for'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/devise-3.2.4/lib/devise/rails/routes.rb:220:in `each'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/devise-3.2.4/lib/devise/rails/routes.rb:220:in `devise_for'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/config/routes.rb:4:in `block in <top (required)>'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/routing/route_set.rb:335:in `instance_exec'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/routing/route_set.rb:335:in `eval_block'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/routing/route_set.rb:313:in `draw'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/config/routes.rb:1:in `<top (required)>'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:223:in `load'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:223:in `block in load'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:214:in `load_dependency'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:223:in `load'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/application/routes_reloader.rb:40:in `each'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/application/routes_reloader.rb:40:in `load_paths'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/application/routes_reloader.rb:16:in `reload!'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/application/routes_reloader.rb:26:in `block in updater'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/file_update_checker.rb:75:in `call'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/file_update_checker.rb:75:in `execute'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/application/routes_reloader.rb:27:in `updater'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/application/routes_reloader.rb:6:in `execute_if_updated'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/initializable.rb:30:in `instance_exec'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/initializable.rb:30:in `run'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/initializable.rb:55:in `block in run_initializers'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/initializable.rb:54:in `run_initializers'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/application.rb:215:in `initialize!'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/railtie/configurable.rb:30:in `method_missing'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/config/environment.rb:5:in `<top (required)>'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `block in require'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:214:in `load_dependency'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/application.rb:189:in `require_environment!'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/application.rb:250:in `block in run_tasks_blocks'
/tmp/build_59a23f0f-d0e9-44ae-8fb5-c417d3b22c35/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.0.1/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 app
To git@heroku.com:gentle-escarpment-8370.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:gentle-escarpment-8370.git'
最后,我的用户
模型:
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :experiences
end
class用户
我不是Ruby或Rails方面的经验丰富的开发人员(我研究该框架不到两个月),但我怀疑Heroku平台与Rails 4.0.4或Desive 3.2.4不兼容
有什么建议吗?您是否运行了
design
安装程序?似乎认为你的应用程序中没有设计初始值设定项
根据,您是否已完成以下操作:
rails generate devise:install
如果您查看错误将是什么,这似乎得到了确认:
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
这是在用户
模型中-意味着您得到的错误是因为这一行。undefined方法
错误意味着您尚未加载应用程序的该部分,原因可能是未安装依赖项(gem
),或者您尚未对其进行初始化
你能确认你有config/initializers/designe.rb
吗?我想你已经解决了这个问题,但万一你没有,这可能会有帮助。我也有同样的问题,我的问题是.gitignore中有./config/initializers/develope.rb文件。您可以尝试更新此文件以解决此问题。您拥有的Rails和Desive版本都应该与heroku一起使用。这是一款使用相同版本的Desive和rails部署的应用程序,没有任何问题。尝试在本地计算机上运行rake-assets:precompile,看看是否无法编译具有相同错误的资产?是的,在推送到heroku Master之前,先执行rake-assets:precompile,然后推送到github repo这就是问题所在。命令rakeassets:precompile在我的机器上运行良好。但当我尝试在Heroku上部署时,它就是不起作用
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable