Rails: working on temporary instance between requests and then commit changes to database -


i have read rails - how temporarily store rails model instance? , similar questions cannot find successful answer.

imagine have model customer, may contain huge amount of information attached (simple attributes, data in other tables through has_many relation, etc...). want application's user access data in single page single save button on it. user makes changes in data (i.e. changes simple attributes, adds or deletes has_many items,...) want application update model, without committing changes database. when user clicks on save, model must committed.

for achieving need model kept rails between http requests. furthermore, 2 different users may changing model's data @ same time, these temporary instances should bound rails session.

is there way achieve this? idea? and, if not, how can 1 design web application in changes in model cannot retained in browser in server until user wants commit them?

edit

based on user smallbutton.com's proposal, wonder if serializing model instance temporary file (whose path stored in session hash), , reloading each time new request arrives, trick. work in cases? there piece of information lost during serialization/deserialization?

as http requests stateless need kind of storeage between requests. session easiest way store data between requests. session not enough because need accessed multiple users.

i see 2 ways achive goal:

1) fast external data storage key-value server (redis, or prefer http://nosql-database.org/) put objects via serializing/deserializing (eg. json). may fast depending on design choices , data model harder approach.

2) store objects in db regularly , them versioned: (https://github.com/airblade/paper_trail). can store timestamp when people hit save-button , can go state. easier approach guess may bit slower depending on size of data model changes ( think it'll )

edit: if need real-time collaboration between users should have @ firebase

edit2: anwer second question, whether can put data file:

sure can that. need kind of locking prevent data loss if more 1 person editing. need aswell if go 1) tools redis include locks achive goal (eg. redis-semaphore). depending on data may need build logic merging different changes of different users.

3) aproach came mind doing editing javascript , save in 1 db-transaction. go synchronization tools firebase (or own synchronization via rails streaming api)


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -