一起使用 Formtastic 和 Globalize2
我用的是Formtastic。现在我想为某些字段添加模型翻译。我查看了 Globalize2,它似乎是我所需要的。但我不知道如何将它与 Formtastic 集成。有人有这样的经历吗?
I use Formtastic. Now I would like to add model translations for some fields. I look at Globalize2 and it seems like what I need. But I have no idea how to integrate it with Formtastic. Does anybody have such experience?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以这很容易。您可以像没有 Formtastic 一样使用它。
在迁移中:
在模型中:
备注:从 Rails 2.3 开始,您可以使用 default_scope 而不是 :joins =>; :globalize_translations。在早期版本的rails中,在Find方法和named_scopes中(例如)你应该写:
In view:
PS: Globalize2 gem 不适合我。所以我不得不使用插件。
So it's quite easy. You can use it in the same manner as you don't have a Formtastic.
In migration:
In model:
One remark: since rails 2.3 you can use default_scope instead of :joins => :globalize_translations. In earlier versions of rails in Find methods and in named_scopes (for example) you should write:
In view:
P.S: Globalize2 gem doesn't work for me. So I had to use plugin.