The below student_request method updates records successfully in Rails but returns "Error #1090: XML parser failure: element is malformed.” in Flash Builder 4 beta. Now the xml works fine for other actions, so I don't think the xml is at fault. It's something in the confirm_request method. Does anyone have any idea?
class StudentRequestsController < RestfulController
def confirm_request
StudentRequest.transaction do
update_common do |student_request|
student_request.creator_id = current_user.contact.contactable
student_request.student_request_status_id = 1
if student_request.save
x = student_request.destination_id
y = student_request.id
end
books = Book.find(:all, :conditions => ["books.location_id = ? && books.student_request_id = ?", x, y])
books.each do |book|
book.student_book = 3
book.save
end
end
end
end
class RestfulController < ApplicationController
def update
update_common { |resource| update_resource(resource) }
end
def update_common(verb="updated")
@resource = find_one_resource params[:id]
self.resource = @resource
respond_to do |format|
if yield(@resource)
format.xml {head :ok }
else
format.xml { render :xml => @resource.errors.to_xml (:skip_types => true, :dasherize => false), :status => :unprocessable_entity }
end
end
def find_one_resource(id)
resource_model.find(id)
end
def update_resource(resource)
resource.update_attributes update_resource_params
end
def update_resource_params
params[resource_params_key]
end