运行rake db:migrate --trace
时遇到以下错误。我的rails版本 - rails 3.2.0。我正在尝试运行项目https://github.com/ninetwentyfour/Hospitium。我是ruby to ruby on rails的新手
错误:
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Invoke disable_rails_admin_initializer (first_time)
** Execute disable_rails_admin_initializer
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:migrate
== **DeviseCreateUsers: migrating** ==============================================
-- **create_table(:users)**
**rake aborted!
An error has occurred, all later migrations canceled:
undefined method `database_authenticatable'** for #<ActiveRecord::ConnectionAdapte
rs::TableDefinition:0x5d49098>
E:/ruby projects/Hospitium Animal Hospital/db/migrate/20110904205556_devise_crea
te_users.rb:4:in `block in up'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/connect
ion_adapters/abstract/schema_statements.rb:160:in `create_table'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/connect
ion_adapters/abstract_mysql_adapter.rb:422:in `create_table'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:450:in `block in method_missing'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:424:in `block in say_with_time'
C:/Ruby193/lib/ruby/1.9.1/benchmark.rb:280:in `measure'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:424:in `say_with_time'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:444:in `method_missing'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:334:in `method_missing'
E:/ruby projects/Hospitium Animal Hospital/db/migrate/20110904205556_devise_crea
te_users.rb:3:in `up'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:358:in `up'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:396:in `block (2 levels) in migrate'
C:/Ruby193/lib/ruby/1.9.1/benchmark.rb:280:in `measure'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:396:in `block in migrate'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/connect
ion_adapters/abstract/connection_pool.rb:118:in `with_connection'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:377:in `migrate'
C:in `migrate'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:704:in `block (2 levels) in migrate'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:761:in `call'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:761:in `ddl_transaction'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:703:in `block in migrate'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:684:in `each'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:684:in `migrate'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:554:in `up'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:535:in `migrate'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/railtie
s/databases.rake:153:in `block (2 levels) in <top (required)>'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:205:in `call'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:205:in `block in execute'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:200:in `each'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:200:in `execute'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:158:in `block in invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:144:in `invoke'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:116:in `invoke_task'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:94:in `block (2 levels) in top_lev
el'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:94:in `each'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:94:in `block in top_level'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handlin
g'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:88:in `top_level'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:66:in `block in run'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handlin
g'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:63:in `run'
C:/Ruby193/bin/rake:32:in `<main>'
Tasks: TOP => db:migrate
我的GEM文件
source 'http://rubygems.org'
gem 'rails', '3.2.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem "eventmachine", "1.0.0.beta.4.1"
gem 'mysql2'
gem 'devise' # Devise must be required before RailsAdmin
gem 'rails_admin'
gem 'nokogiri'
gem 'mechanize'
gem 'uuidtools'
gem 'cancan'
gem 'paperclip'
gem 'aws-sdk', '~> 1.3.4'
gem 'will_paginate'
gem 'paper_trail'
gem 'oauth'
#gem 'twitter'
gem 'rest-client'
gem 'json'
#gem 'libxml-xmlrpc'
gem 'bitly'
gem 'site_meta'
gem 'meta_search'
gem 'airbrake'
gem 'spork', '~> 1.0rc'
gem 'client_side_validations'
gem 'jqplot-rails'
gem 'asset_sync'
gem 'gravatar_image_tag'
gem 'best_in_place'
gem 'juggernaut'
gem 'jquery-rails'
#gem 'less-rails-bootstrap'
gem "spreadsheet", "0.6.5.8"
gem 'to_xls'
gem 'sanitize'
gem 'redcarpet'
gem 'rqrcode-rails3'
gem 'octokit'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem 'closure-compiler'
end
group :development do
gem 'metrical'
end
group :production do
gem 'home_run', :require=>'date'
#gem 'slim_scrooge', :git => "git://github.com/sdsykes/slim_scrooge.git"
gem 'dalli'
gem 'thin'
gem 'pg'
gem 'newrelic_rpm'
gem 'heroku'
end
gem "rspec-rails", :group => [:test, :development]
group :test do
gem "factory_girl_rails"
gem "capybara"
#gem 'capybara-webkit'
gem 'shoulda-matchers'
gem 'cucumber-rails', :require => false
gem 'database_cleaner'
gem 'launchy'
gem 'email_spec'
end
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
----------------------------------------------------------------------------------------
根据Said Kaldybaev解决方案,我试过
E:\ruby projects\Hospitium Animal Hospital>rails g devise:install
conflict config/initializers/devise.rb
Overwrite E:/ruby projects/Hospitium Animal Hospital/config/initializers/devise.
rb? (enter "h" for help) [Ynaqdh] h
Y - yes, overwrite
n - no, do not overwrite
a - all, overwrite this and all others
q - quit, abort
d - diff, show the differences between the old and the new
h - help, show this help
Overwrite E:/ruby projects/Hospitium Animal Hospital/config/initializers/devise.
rb? (enter "h" for help) [Ynaqdh] a
force config/initializers/devise.rb
identical config/locales/devise.en.yml
===============================================================================
Some setup you must do manually if you haven't yet:
1. Ensure you have defined default url options in your environments files. Her
e
is an example of default_url_options appropriate for a development environm
ent
in config/environments/development.rb:
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
In production, :host should be set to the actual host of your application.
2. Ensure you have defined root_url to *something* in your config/routes.rb.
For example:
root :to => "home#index"
3. Ensure you have flash messages in app/views/layouts/application.html.erb.
For example:
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
如果要在Heroku上部署Rails 3.1,则可能需要设置:
config.assets.initialize_on_precompile = false
在config / application.rb上强制您的应用程序无法访问数据库 或在预编译资产时加载模型。
=============================================== ================================
E:\ ruby projects \ Hospitium Animal Hospital&gt; rails g devise user 调用active_record 另一个迁移已经命名为add_devise_to_users:E:/ ruby projects / Hospiti 动物医院/ db / migrate / 20120518093709_add_devise_to_users.rb
E:\ ruby projects \ Hospitium Animal Hospital&gt; rake db:migrate == DeviseCreateUsers:迁移============================================= = - create_table(:users) 耙子流产了! 发生错误,所有后续迁移都已取消:
对于#,未定义的方法`database_authenticatable'
任务:TOP =&gt; DB:迁移 (通过使用--trace运行任务查看完整跟踪)
答案 0 :(得分:0)
请重新运行这些命令,它可以正常工作
rails g devise:install
rails g devise user
rake db:migrate
答案 1 :(得分:0)
那时的回购似乎有问题,https://github.com/ninetwentyfour/Hospitium, 现在它的工作正常。