Ruby on Rails ActiveRecord:多元化
我是 Rails 新手,请原谅我对 ActiveRecord 的无知。我的模型之一名为“校园”。我进行了迁移,它使除“校园”之外的所有内容都多元化。
我认为这很蹩脚,所以我将代码添加到环境配置中,以使一切保持单一。
我删除了表,手动编辑迁移文件以使用单数形式,然后重新运行迁移。现在我对“校园”的联想不再起作用了。我通过控制台运行它,注意到我得到了一个未初始化的常量“Campu”。那么有些人仍然认为“校园”是复数吗?我是否应该假设配置更改只会给我带来麻烦?
I'm new to Rails, so forgive my ignorance of ActiveRecord. One of my models is named "campus". I ran the migration and it pluralized everything except "campus".
I thought that was lame so I added the code to the environment config to leave everything singular.
I deleted the tables, manually edited the migration files to use singular forms, and re-ran the migrations. Now my associations to "campus" no longer work. I ran it through the console and noticed that I'm getting an uninitialized constant "Campu". So something still thinks "campus" is plural? Should I assume that config change will cause me nothing but trouble going forward?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用自定义变形。请参阅此相关问题:如何覆盖 Rails 命名约定?
Use custom inflections. See this related question: How do I override rails naming conventions?