【发布时间】:2012-05-06 19:31:59
【问题描述】:
我有这个模型
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 上创建一个“noticias”时,它会出现在一个名为“noticias”的集合中。另外,notcias 集合没有 tags 字段,这对我的应用程序非常重要,可以在 noticia 上执行搜索
有什么想法吗?
【问题讨论】:
-
有人吗?尝试删除行
inflect.irregular 'noticia', 'noticias',但也没有用 -
我试了一下,结果对我有用。我确实注意到,如果我把它放在 Application.initialize 之后,它并没有生效!在环境中.rb。你把它放在哪里了?你能用 noticia --> noticia 在本地重现你的问题吗?我还没有尝试使用heroku,因为我能够让noticias --> noticias 在本地变形。可根据要求提供测试代码。
-
是的,你是对的。放在
Application.initialize!之前就成功了
标签: ruby-on-rails ruby-on-rails-3 mongodb mongoid mongohq