mongoid在mongohq上创建不同的集合

时间:2012-05-06 19:32:00

标签: ruby-on-rails ruby-on-rails-3 mongodb mongoid mongohq

我有这个模型

class Noticia
  include Mongoid::Document
  include Mongoid::Timestamps
  include Mongoid::Slug

  belongs_to :user

  field :titulo, :type => String
  field :conteudo, :type => String
  field :tags, :type => Array

  index :tags
  slug :titulo
end

有了这个环境

ActiveSupport::Inflector.inflections do |inflect|
  inflect.irregular 'inscricao', 'inscricoes'
  inflect.irregular 'noticia', 'noticias'
  inflect.irregular 'central', 'centrais'
end

当我在本地创建'noticia'时,它会在集合'noticia'上创建。但是当我在heroku上创建一个'noticia'时,它出现在一个名为'noticias'的集合中。另外,notcias集合没有tags字段,这对我的应用来说非常重要,可以在noticia上执行搜索

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

很高兴听到在Application.initialize之前调用inflect!解决了你的问题。