Hi All,
I am new to ruby on rails,we are developing a integrated application which can be accessed by many companies…
We developed application on development environment,recently we switched to production environment as per client request.The insertion operation working fine where are the updation not working…
Updation working for sometimes if it is done consecutively then it is not working,If the server restart it is working again upto some requests…
My Code is
def UpdateToDB
hash = params[:object].to_hash
key = hash[‘key’]
if key==nil then # since the operation is generic
puts " the key not coming thourgh xml"
return nil
end
value = hash[key.to_s]
model = hash[‘model’]
record = model.find(:all,:conditions=>[“#{key}=?”,value]) # retriving the record from db
updateRecord = model.new(hash[‘record’]) # record with updated fileds ,consits every filed in the record except the key value,attribute
updateRecord.TimeUpdate = DateTime.now
Here whatever the other requirements and conversions
added to the updateRecord and also checking the required fields to be non empty etc;
recordHash = Hash.from_xml(updateRecord.to_xml)
root = recordHash.keys
rootElement = root(0)
if record.update_attributes(recordHash[rootElement.to_s]) then
puts record.to_xml
puts “saved successfully”
redirect_to ‘index’
end
end
The above method working fine for updation upto some requests only… like 8 updates not more than… for the 9th update the statement record.to_xml showing the updated value in the server but it is not get updated in the database…
Can anyone solve my problem and save my day…
Thanks