【问题标题】:Vanity not works with MySql虚荣心不适用于 MySql
【发布时间】:2011-10-29 06:23:09
【问题描述】:

我尝试为我的 rails 2.3.5 应用程序安装 Vanity gem,我想使用 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

我在环境文件 development.rb 中添加了:

Vanity.playground.establish_connection :development
Vanity.playground.collecting = true

所以它必须对包含在虚荣宝石中的适配器做一些事情,因为 redis 运行完美。谁知道解决方案?

【问题讨论】:

    标签: mysql ruby-on-rails activerecord redis vanity


    【解决方案1】:

    我还没有弄清楚这个问题的原因,但我通过更明确地使用 active_record_adapter.rb 文件中的 has_many 关联的类名来让它工作:

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

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

    【讨论】:

    猜你喜欢
    • 2011-12-17
    • 1970-01-01
    • 1970-01-01
    • 2011-01-20
    • 1970-01-01
    • 2011-09-13
    • 1970-01-01
    • 2019-08-09
    相关资源
    最近更新 更多