There are actually 3 parts to this question.  I have found a solution
to each. 

The first part is how to create a new simulation given the data for a
simulation, server, load and buffer.  I resolved this in my
simulations_controller#create method.  The trick linking up the newly
created entities (server, load, buffer) to the new simulation.  I
discovered that the << operator does not work the way that I expected
it to after reading the documentation, so I got rid of that and set
the foreign key id in code .  Here's a snippet which creates the
simulation and the buffer:

@simulation = Simulation.new(sim_hash)
@simulation.user_id = current_user.id
@simulation.save!   #need to save to get the id from the database

buf = Buffer.new(buf_hash)
buf.name='Queue1'
[email protected]
buf.save!

Because save! returns an exception if it fails, I surround the whole
sequence with a rescue block to catch an ActiveRecord::RecordInvalid
exception.  

The second problem is that my server and load were failing validation.
 This was a problem with the data from my ComboBox items.  When using
SelectedItem we get a hash that contains the ComboBox's internal id,
the label and the value.  I had to extract the value out of that when
sending the data using my HTTPService. Once I got just the value from
the ComboBox and not the whole object, the items passed validation.   

The 3rd problem here is that IE returns a 2032 Stream Error when
status code 201 is returned from the POST.  (FireFox doesn't do this).
 The last line of the log file on my original post is:

 0.12400 (65%) | 201 Created [http://localhost/simulations.xml]

The symptom of this is that the data is saved correctly to the
database, but I still get a 2032 Stream Error on the UI after I click
the save button.  When I reload the application, the new data is
there; when I explore my data base, the data is there, but I get that
nasty 2032 error and my UI is in an inconsistent state.

For a solution to this problem, see my post at
http://stackoverflow.com/questions/354936/flex-2032-stream-error-in-ie-only

LG Rains




Reply via email to