将现有 Sinatra 应用程序(+datamapper)迁移到 Rails 3(+active record)的最佳实践是什么?
当迁移使用 Sinatra 和 Datamapper 构建的现有 Web 应用程序时,如何将其迁移到 Ruby on Rails (v3.1) 和 ActiveRecord 应用程序?
例如,首先迁移到 ActiveRecord,同时仍然使用 Sinatra。完成后,转移到控制器等。或者反过来,从迁移控制器开始,然后继续使用 Datamapper。
我认为在生产环境中实际运行部分迁移的代码并不是一个好主意,但我确实喜欢以结构化方式进行迁移,这样我就可以一次解决一个问题。
When migrating an existing web application built using Sinatra and Datamapper, how would one go about migrating it to a Ruby on Rails (v3.1) and ActiveRecord application?
For example, start by migrating to ActiveRecord first while still using Sinatra. Once completed, move to controllers, etc. Or perhaps the other way around, start with migrating the controllers and continue using Datamapper at first.
I don't think it's a good idea to actually run the partly migrated code in a production environment, but I do like to migrate in a structured way so I can solve one problem at a time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法从 DataMapper 迁移到 ActiveRecord,这会适得其反。 DataMapper 的抽象级别比ActiveRecord 的要高得多。
然而,跳转到 Rails,您可能会发现很多使用非常好的插件或宝石的糖分,这些宝石不以与 Sinatra 的友谊而闻名。
尝试搜索声称支持与框架无关的 gem,并且仅依赖于 Rack 和/或 ActiveModel,而不依赖于 Rails。
You can't migrate from DataMapper to ActiveRecord, that is counterproductive. The level of abstraction of DataMapper is way higher than the ActiveRecord's.
However, jumping to Rails you may find lots of sugar using very nice plugins or gems not known for friendship with Sinatra.
Try searching for gems that claims framework agnostic support and depends on just Rack and/or ActiveModel, not Rails.