gpt4 book ai didi

mysql - Rails 一直尝试使用 SQLite ,尽管我已经为我的项目配置了 MySQL

转载 作者:行者123 更新时间:2023-11-29 02:37:50 24 4
gpt4 key购买 nike

我使用以下方法设置我的 Rails 项目“rails ”:

$ rails --database=mysql tracks # OK
$ cd tracks
$ vim config/database.yml # correct using mysql adapter, added password spec
$ rake db:create RAILS_ENV='development' # OK
$ rake db:migrate # OK

$ ruby script/generate scaffold user name:string password:string email:string url:string # OK
$ rake db:migrate # OK, creates table
$ ruby script/server # OK, starts WEBrick

我在网络浏览器中打开这个东西:

http://localhost:3000 # correctly shows the rails welcome splash

我导航到

http://localhost:3000/users/new

并得到大量的错误:

ActiveRecord::StatementInvalid in UsersController#index

SQLite3::SQLException: no such table: users: SELECT * FROM "users"
RAILS_ROOT: /home/drew/tracks/trunk/tracks

Application Trace | Framework Trace | Full Trace
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:188:in `log'
vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:132:in `execute'
vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:372:in `catch_schema_changes'
vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:132:in `execute'
vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:275:in `select'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:60:in `select_all'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:81:in `cache_sql'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:60:in `select_all'
vendor/rails/activerecord/lib/active_record/base.rb:635:in `find_by_sql'
vendor/rails/activerecord/lib/active_record/base.rb:1490:in `find_every'
vendor/rails/activerecord/lib/active_record/base.rb:589:in `find'
app/controllers/users_controller.rb:5:in `index'

怎么回事?为什么 ruby​​ 还在尝试使用 SQLite? database.yml 零提及 SQLite。

谢谢

最佳答案

想不通。我最终在 VM 上重新安装操作系统并再次尝试,它成功了。

仅供引用:不要从 apt-get 等包管理器安装 ruby​​gems。从源代码编译它,否则它将以泪水告终。

关于mysql - Rails 一直尝试使用 SQLite ,尽管我已经为我的项目配置了 MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2394757/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com