使用离线存储
我正在尝试制作一个网站,将用户的所有联系人存储在服务器数据库上。用户可以添加、编辑、删除或更新联系人。我希望用户即使在离线状态下也能够执行所有这些功能。我应该用什么来实现这个目标。我遇到了 Web sql 数据库,它可以用来离线存储数据库。但不知道如何同步线上和线下数据库。我正在使用 Ruby on Rails
I am trying to make a website which will store all the contacts of the user on the server database. The user can add, edit, delete or update a contact. I want the user to be able to do all these functionality even when he is offline. What should I use to achieve this. I came across web sql database which can be use to store database offline. But I dont know how to synchronise the online and offline database. I am using Ruby on Rails
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据 Web SQL 的 W3C 页面,该规范不再处于主动维护状态,并且 Web 应用程序工作组不打算进一步维护它 (http://www.w3.org/TR/webdatabase/)。
为什么不尝试一下 HTML5 的持久存储呢? 这里有一个很棒的教程,其中有一章介绍 HTML5 之前的本地存储技巧,因此您可以阅读它:您还不打算深入研究 HTML5。
您还可以尝试 Google Gears,因为它具有本地 sqlite3 数据库的接口,您可以在其中使用可能会存储您的离线数据。
至于同步机制,请尝试 persistanceJS。它应该可以帮助您使用 HTML5 和 Google Gears 选项。
编辑
显然persistanceJS还不支持rails,但是有一个关于如何使用rails本地HTML5存储的教程这里,还有一个 Rails 插件可以轻松启用 Rails 应用上的 Gears 此处。这些应该可以帮助你开始。
According to Web SQL's W3C page, the specification is no longer in active maintenance and the Web Applications Working Group does not intend to maintain it further (http://www.w3.org/TR/webdatabase/).
Why don't you give HTML5's persistent storage a try instead? There's a great tutorial here that also features a chapter on local storage hacks before HTML5, so you may read it if you're not planning to dive into HTML5 just yet.
You may also try Google Gears, as it features an interface to a local sqlite3 database in which you may store your offline data.
As for the synchronization mechanism try persistanceJS. It should help you with both HTML5 and Google Gears options.
EDIT
Apparently persistanceJS has no support for rails just yet, but there's a tutorial on how to use local HTML5 storage with rails here, and there's a rails plugin to easily enable gears on rails apps here. Those should get you started.
您也可以使用 Ruby on Rails 来完成此操作。查看 Railscast 系列视频教程。具体来说,第 247 集开始使用 ROR 和离线存储
You can use Ruby on Rails to do it as well. Check out the Railscast series of video tutorials. Specifically episode 247 to get started with ROR and offline storage