Doubt on Models

I have two tables in my db
x_configs, x_things
the models are
XConfig, XThing
XThing belongs :x_config

now in my application when i want to add new “xthing”, it has to have an existing “x_config”, as I have a “x_config_id” in the “x_things” table,which at creation of “x_thing” i pass as a parameter from params, but if i want to start my app without populating “x_configs”

and create “xthing”,
so i create “x_config” just after i trigger a create “xthing” action, so that it then takes that id and starts creating “xthings,”
But i am getting an error still saying that i am trying to get nil id ,

but in database the row is created in “x_configs”

if the above desctiption of problem is ugly , please tell me , or if you can give a solution that would be great

sekhar