_create method doesn't seem to be writing to DB

I have two models, A and B where B blongs_to A and A has_many B.

I have a view that does “new” on B and then I call a create method on
B which then makes the call @B.create_A(params[:wanted_offer])

All runtime indications seem OK (no error, barfs, etc.) - the logs
seem ok too but A does not seem to be getting written in the table.

What am I missing?

On Thu, Feb 14, 2008 at 8:03 PM, nahabed [email protected] wrote:

I have two models, A and B where B blongs_to A and A has_many B.

I have a view that does “new” on B and then I call a create method on
B which then makes the call @B.create_A(params[:wanted_offer])

What’s @B here? It would seem to be an instance variable of some
object, but it’s wierd to be in uppercase.

All runtime indications seem OK (no error, barfs, etc.) - the logs
seem ok too but A does not seem to be getting written in the table.

What am I missing?

Does A have any validations which might be failing? Remember that the
active record create and save methods will just return false if the
record fails validation. The create! and save! will raise an
exception.

If b is an instance of B then you might want to use
b.a.create!(params[:wanted_offer]]

or at least check the return of create.


Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

Sorry for the confusion (B) i didn’t follow the convention. It is an
instance variable and what you suggested worked! thanks.