Having a problem initializing an associated table

Q. What am I doing wrong such that tx_batch_mtime is not receiving the
value I believe that I am assigning? At this point current_entry has
not itself been saved.

I have this code:

puts( "*** ***" *3 )

      current_log_entry = current_entry.edi_log_entries.build

puts( current_log_entry.class )
puts( hash[:current_batch][:tx_batch_mtime] )

      current_log_entry.tx_batch_mtime = \ # linebreak for clarity
        hash[:current_batch][:tx_batch_mtime]

puts( current_log_entry.to_yaml )
puts( current_entry.cctn )
puts()

Which produces this output:

      *** ****** ****** ***
      CaCustomsEdiLogEntry
      1276181402
      --- !ruby/object:CaCustomsEdiLogEntry
      attributes:
        tx_batch_number:
        created_at:
        changed_by: " "
        tx_message_function:
        tx_record_type:
        tx_batch_date:
        lock_version: 0
        tx_batch_account:
        created_by: " "
        accessed_at:
        tx_batch_mtime:
        tx_message_data:
        changed_at:
        accessed_from: " "
        ca_customs_entry_id:
        accessed_by: " "
      attributes_cache: {}

      changed_attributes: {}

      destroyed: false
      marked_for_destruction: false
      persisted: false
      previously_changed: {}

      readonly: false
      13466600016294

      1276181402
      20100610
      13466
      009

As you can see, current_edi_log.tx_batch_mtime is nil whereas I expect
it to be 1276181402. Why?

Q. What am I doing wrong such that tx_batch_mtime is not receiving the
value I believe that I am assigning? At this point current_entry has
not itself been saved.

I have this code:

puts( "*** ***" *3 )

 current\_log\_entry = current\_entry\.edi\_log\_entries\.build

puts( current_log_entry.class )
puts( hash[:current_batch][:tx_batch_mtime] )

 current\_log\_entry\.tx\_batch\_mtime = \\   \# linebreak for clarity

The \ must be the last char on the line, though I would have expected
this to generate a compile error.

If still not working use ruby-debug to break into the code and inspect
data to see what is going on. See Rails Guide on debugging if unsure
how to do this. I is often a lot easier than loads of debug o/p.

Colin

Colin Law wrote in post #980132: