我试图为我的Rails2.3.5应用程序安装VanityGem,我想为Vanity使用MySQL。当我用redis配置时一切都很好,但是当我将配置文件更改为使用mysql时:

development:
  adapter: active_record
  active_record_adapter: mysql
  host: localhost
  database: vanity
  username: root
  password:

我得到以下错误:
Showing
/Users/dries/.rvm/gems/ruby-1.8.7-p302/gems/vanity-1.5.3/lib/vanity/templates/_ab_test.erb where line #1 raised:

Vanity::Adapters::ActiveRecordAdapter is not missing constant
VanityConversion! Extracted source (around line #1):

1: <% score = experiment.score %>
2: <table>
3:   <caption>
4:     <%= experiment.conclusion(score).join(" ") %></caption>

Trace of template
inclusion:
/Users/dries/.rvm/gems/ruby-1.8.7-p302/gems/vanity-1.5.3/lib/vanity/templates/_experiment.erb,
/Users/dries/.rvm/gems/ruby-1.8.7-p302/gems/vanity-1.5.3/lib/vanity/templates/_experiments.erb,
/Users/dries/.rvm/gems/ruby-1.8.7-p302/gems/vanity-1.5.3/lib/vanity/templates/_report.erb

我在environment file development.rb中添加了:
Vanity.playground.establish_connection :development
Vanity.playground.collecting = true

所以它必须使用包含在VanityGem中的适配器,因为Redis工作得很完美。有人知道解决办法吗?

最佳答案

我还没有找到原因,但我通过在active_record_adapter.rb文件中更明确地使用has_many association的类名来解决这个问题:

has_many :vanity_metric_values, :class_name => "Vanity::Adapters::ActiveRecordAdapter::VanityMetricValue"
has_many :vanity_conversions, :dependent => :destroy, :class_name => "Vanity::Adapters::ActiveRecordAdapter::VanityConversion"

编辑:在第一次启动Vanity时,这似乎会中断迁移过程(我正在努力解决这个问题!),但可能会帮助您找到解决方案。

关于mysql - 虚荣不适用于MySql,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7099016/

10-11 22:12
查看更多