gpt4 book ai didi

mysql - Rails 3 和 MySQL 的问题与 ActiveSupport 中的 JSON 依赖相关

转载 作者:可可西里 更新时间:2023-11-01 06:50:31 28 4
gpt4 key购买 nike

我使用 sqlite 构建了我的 Rails 3 应用程序,现在我正尝试切换到 MySQL。

我创建了一个新的 MySQL 数据库,相应地更改了 database.yml,并将旧版本的 mysql2 gem 添加到我的 gemfile ( gem 'mysql2', '< 0.3' ) 中,它应该是 play nicer with Rails 3 .

我可以正常启动开发服务器。当我访问一个页面时,我得到一个 Mysql2::Error (Table 'twitter_quiz_development.users' doesn't exist)。这很好——我仍然需要将模式添加到新数据库中。这是我遇到麻烦的地方:

rake db:schema:load返回 this nasty error .

找到的解决方案here没有为我工作。 gem pristine --all返回 this .

如果有帮助,我正在运行 Ubuntu 11。

看来错误与 JSON 有关,但我不知道如何解决这个问题。谢谢。

最佳答案

您遇到的问题可能是由于 3 件事造成的:

  • 您使用的 Ruby 版本
  • 在 Ruby 1.9 中使用 SystemTimer gem
  • JSON gem

我在下面详细说明了...

我建议的第一件事是升级您的 Ruby 1.9 版本。最新的稳定版是:

ruby 1.9.2p180 (2011-02-18 revision 30909)

我强烈推荐使用 Ruby Version Manager (RVM)安装和管理 Rubies。

在使用 JSON gem 方面,请查看: http://ruby.about.com/od/tasks/a/The-Json-Gem.htm

引用:

On Ruby 1.8.7, you'll need to install a gem. However, in Ruby 1.9.2, the json gem is bundled with the core Ruby distribution. So, if you're using 1.9.2, you're probably all set. If you're on 1.8.7, you'll need to install a gem.

Before you install the JSON gem, first realize that this gem is distrubuted in two variants. Simply installing this gem with gem install json will install the C extension variant. This requires a C compiler to install, and may not be available or appropriate on all systems. Though if you can install this version, you should.

If you can't install the C extension version, you should gem install json_pure instead. This is the same gem implemented in pure Ruby. It should run everywhere that Ruby code runs, on all platforms and on a variety of interpreters. However, it's considerably slower than the C extension version.

编辑:

看起来你应该避免在 Ruby 1.9 中使用 SystemTimer gem。有关更多信息,请参见:http://isitruby19.com/systemtimer

引用 Phillipe 在该页面上发表的评论:

I am the (co)-author of this gem. Short story : Using this gem in Ruby 1.9 is useless and does not make any sense!

System Timer is trying to work around some limitation of the "green thread" model used in Ruby 1.8 (MRI). See http://ph7spot.com/musings/system-timer for more details.

It is then irrelevant in a Ruby 1.9 which abandoned the green thread model and embraced native threads (kind of since there is still a global interpreter lock).

Cheers, - Philippe

关于mysql - Rails 3 和 MySQL 的问题与 ActiveSupport 中的 JSON 依赖相关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6221854/

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