I'm trying to save a variable called persistent_data
.
I usually use session[:persistent_data]
or cookies[:persistent_data]
, but I would like to use the localstorage instead.
How do I do that on Rails?
I'm trying to save a variable called persistent_data
.
I usually use session[:persistent_data]
or cookies[:persistent_data]
, but I would like to use the localstorage instead.
How do I do that on Rails?
As far as I know localStorage has nothing to do with Rails, it is pure Javascript/HTML5 feature.
You can use the following in you application js in order to read or write data from the local storage:
Localstorage has nothing to do with rails. You do it the same way as with any other language:
You can use rails to dynamically set the item however:
As others have already said local storage is Javascript/Html feature/solution but if wanting to learn how to integrate that with rails Ryan Bates has a railscast at http://railscasts.com/episodes/248-offline-apps-part-2, though you might need to watch part 1 to fully understand it.