我尝试在我的应用上运行db:migrate并且我收到此错误。不确定原因是什么。
ruby版本:ruby 2.2.6p396(2016-11-15修订版56800)[i386-mingw32] 我已经完成了谷歌搜索,但我没有得到任何东西。任何人都可以解释这个错误吗?
NotImplementedError:NotImplementedError
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-5.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:85:in exec_query'
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-5.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:377:in 'select_prepared'
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-5.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:39:in
select_all&#39 ;
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-5.0.1/lib/active_record/connection_adapters/abstract/query_cache.rb:95:in select_all'
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-5.0.1/lib/active_record/querying.rb:39:in
find_by_sql&#39 ;
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-5.0.1/lib/active_record/relation.rb:702:在`exec_queries'
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rake-12.0.0/exe/rake:27:in <top (required)>'
C:/RailsInstaller/Ruby2.2.0/bin/rake:23:in
loading&#39;
C:/RailsInstaller/Ruby2.2.0/bin/rake:23:在'&#39;
任务:TOP =&gt;分贝:
迁移
答案 0 :(得分:0)
你可以试试这个..
检查您的config/database.yml
文件。
config/database.yml
必须与username
相似,password
应更改mysql
username
,password
。
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: username
password: password
socket: /var/run/mysqld/mysqld.sock
development:
<<: *default
database: uBuild-rails_development
test:
<<: *default
database: uBuild-rails_test
production:
<<: *default
database: uBuild-rails_development
username: username
password: password
同时检查Gemfile
gem 'mysql2', '< 0.3' # as stated above
答案 1 :(得分:0)
我遇到了同样的问题,我所做的是使用此命令再次创建项目:
rails new my_project -d=mysql
这样就可以自动创建database.yml和gemfile中的配置,避免出现问题。您只需编辑database.yml mysql密码即可使用
rails g scaffold Examples attrib1:string attrib2:string
创建视图等
rake db:create
创建数据库然后
rake db:migrate
希望这会有所帮助...
答案 2 :(得分:0)
数据库文件位于config / database.yml中,配置为
default: &default
adapter: mysql2 #if use postgres the add postgresql
pool: 5
timeout: 5000
username : username #mysql username
password : password #mysql password
development:
<<: *default
database: application_name
test:
<<: *default
database: application_name
production:
<<: *default
database: application_name
运行以下命令来设置数据库:
run rake db:create
run rake db:migrate