【问题标题】:Problem switching from DataMapper to Active Record in Rails 3在 Rails 3 中从 DataMapper 切换到 Active Record 的问题
【发布时间】:2010-12-22 23:07:13
【问题描述】:

我已在我的 Rakefile 中删除了我的 DataMapper 特定模型和 gem,并删除了所有数据库。我还更新了我的 database.yml 文件。现在,当我尝试使用

rails g model Car year:integer make:string model:string

我明白了:

No value provided for required options '--orm'

我是否有遗漏 Active Record 规范的地方?我一直找不到任何用于切换应用程序 ORM 的文档。

【问题讨论】:

    标签: ruby-on-rails activerecord ruby-on-rails-3 datamapper


    【解决方案1】:

    看看config/application.rb,你可能有这样一行:

    config.generators do |g|
      g.orm :datamapper
    end
    

    :datamapper 符号更改为 :active_record 或完全删除该行以切换回 ActiveRecord。

    如果它不存在,您可能在 config/initializers 中有一个文件,它会为您完成此设置。

    【讨论】:

    • 我在这两个地方都找不到生成器或数据映射器的任何配置,所以我添加了您提到的 config.generators 块:active_record 并尝试再次生成模型,这给了我:错误 active_record [未找到]
    • activerecord gem 添加到您的 Gemfile 并按照 Ryan 的建议运行 bundle install
    • @jdscosta91 我认为 OP 现在可能已经解决了他们的问题 ;)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-25
    • 1970-01-01
    • 2012-06-11
    • 1970-01-01
    • 2018-01-14
    相关资源
    最近更新 更多