On 12 November 2012 19:42, byrnejb <[email protected]> wrote:
> Perhaps this is a Rails issue.  However, I need to first determine whether I
> simply am missing something about updating members of an array.
>
> I have an array of 10 ActiveRecord objects.  I wish to iterate over the
> array and update an attribute.  When I do this the underlying table row
> changes but the object in the array frequently does not. For example:
>
>   count = 0
>   current_entries.each do |entry|
>     puts( entry.object_id )
>     puts( current_entries[count].object_id )
>     puts( "***" )
>     puts( entry.lock_version )
>     entry = set_customs_entry_status_for( entry, status )

You have not shown us set_customs_entry_status_for but it might be
informative to try a
     puts( entry.object_id )
here.

Colin

>     puts( entry.lock_version )
>     current_entries[ count ] = entry
>     puts( current_entries[ count ] = entry )
>   end
>
> gives:
>       58380880
>       58380880
>       ***
>       0
>       5
>       5
>       58378260
>       61590300
>       ***
>       0
>       5
>       5
>       58377460
>       58392560
>       ***
> .  .  .
>
> immediately followed by:
>
>   current_entries.each do |entry|
>     puts( entry.lock_version )
>   end
>
> gives:
>       0
>       5
>       5
>       5
>       0
>       0
>       0
>       0
>       0
>       0
>       0
>       0
>       0
>
> Does anyone see what it is that I am doing wrong?  Why are some, but not
> all, of the objects in the array unchanged?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to