1602/jugglingdb — Issue #31: find sometimes returns an object without an id
Author: nesterko
Created: 2012-02-17 18:26:04+00:00
State: open

Hi,

What I have experienced recently is that sometimes after updateAttributes(), find() returns an object by id, but there is no id element in it (so this property is undefined). This ends up interfering with the code, so I ended up assigning id explicitly in the callback:

7 before 'load role', ->
8 console.log "Looking up role id : " + params.id
9 Role.find params.id, (err, role) =>
10 if err
11 redirect path_to.admin_roles
12 else
13 role.id = params.id
14 @role = role
15 console.log "Here it is : "
16 console.log JSON.stringify @role
17 ## also load role privileges
18 role.privileges (err, privileges) =>
19 if err
20 redirect path_to.admin_roles
21 else
22 @roleprivileges = privileges
23 @roleprIDs = privileges.map (el) -> el.id
24 next()
25 , only: ['show', 'edit', 'update', 'destroy']

One scenario when this happens is in the standard crud generation rw g crud post title content --tpl jade, then rw server 8888, then create a post, then click edit, then update post, then edit again.

I do not know why sometimes find does not return id with the object, I am having trouble recreating this in rw console.

Thanks.