Saving to mysql while displaying a partial that calls for the list of mysql items lags


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 =

if SglineItem.find(:first, :conditions => ['sguser_id =? and

groceries_id =?’, params[:ad], params[:bd]])== nil

@item =
@item.sguser_id= params[:ad]


@item = SglineItem.find(:first, :conditions => ['sguser_id =? and

groceries_id =?’, params[:ad], params[:bd]])
@item.quantity +=1!


respond_to do |format|


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?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs