从 Rails 应用程序访问 HTML5 本地存储

问题描述:

有没有办法从 Ruby On Rails 应用程序访问 HTML5 本地存储?如果有任何 gem/javascript 库(backbone.js 除外,因为使用它重写现有应用程序太困难),请给我一个链接和好的教程.如果你有自己的代码来解决这个问题,我也会很高兴:) 谢谢!

Is there any way to access HTML5 Local Storage from Ruby On Rails application? If there is any gem/javascript library (excepting backbone.js, because it is too difficuilt to rewrite existing app using it), please give me a link and good tutorial. And if you have your own code , that solves this problem, I'll be also happy :) Thanks!

据我所知,localStorage 是纯 Javascript/HTML5 特性.与导轨无关

As far as I know, localStorage is pure Javascript/HTML5 feature. there is nothing to do with rails

您可以在应用程序 javascript 中使用以下内容来读取或写入本地存储中的数据:

You can use the following in you application javascript in order to read or write data from the local storage:

$('.add-hotel').click(function(){ 
item = localStorage.getItem('bucket_data');
});