tyliong
2008-Sep-03 16:59 UTC
saving to mysql while displaying a partial that calls for the list of mysql items lags
Hi, Originally this was part of my highlighting question but now after debugging and slicing up the problem i found that the problem was not rjs but that saving to database does not sync with the ajax partial Controller code: ____________________________________________ def add_to_cart @sguser = Sguser.find(params[:ad]) @lineprice = SglineItem.find(:all, :conditions => "sguser_id #{params[:ad]}") if SglineItem.find(:first, :conditions => [''sguser_id =? and groceries_id =?'', params[:ad], params[:bd]])== nil @item = SglineItem.new @item.sguser_id= params[:ad] @item.groceries_id=params[:bd] @item.save! else @item = SglineItem.find(:first, :conditions => [''sguser_id =? and groceries_id =?'', params[:ad], params[:bd]]) @item.quantity +=1 @item.save! end respond_to do |format| format.js end end _______________________________________ although the @item is saved into the mysql database when respond_to do |format| is evoked it does not see any of the changes. am I right to say that the save and the ajax call are being sent together in the same stream of data? hence the data that is saved into the mysql database while the partial displays the products of the database before the save is noticed? is there a way to break the data into 2 seperate streams and delay the stream for the ajax ? What is the normal procedure for displaying ajax partials that update database information? do i have to use session data to store the products then save them to the database? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---