Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


updateAttributes not working properly on Mongoose #35

nesterko opened this Issue · 2 comments

2 participants


There was an issue before about Boolean type not updating properly. In addition to that, even String type does not update consistently.

For example, we want to update one field F1. It is not updated unless in addition to F1 we make a dummy change to at least one another field (for example, F2). For some fields such trick is not necessary, for some you need it.

I am having trouble determining what is the reason behind this kind of behavior. Would be great if you could shed some light on this.

All fields are String, database is Mongoose. Thank you.


Alright, here are the main ingredients:

Model declaration:
Privilege = describe 'Privilege', () ->
property 'slug', String, index : true
property 'name', String
property 'activated', String, default: "no"

update inside a controller:
action 'update', ->
@privilege.updateAttributes body, (err) =>
if !err
flash 'info', 'Privilege updated'
redirect path_to.admin_privilege(@privilege)
flash 'error', 'Privilege can not be updated'
@title = 'Edit privilege details'
render 'edit'

_form.jade partial within views:
!= form.label("name")
!= form.input("name")
!= form.label("slug")
!= form.input("slug")
!= form.label("activated")
- if (privilege.activated === "yes")
input(type="checkbox", name="activated", value="yes", checked)
- else
input(type="checkbox", name="activated", value="yes")

The only field that has trouble updating under this setup is 'activated', to update it I need to change say 'name' together with it. Changing just 'activated' does not do the trick.

This setup works fine under driver : memory.

Please let me know if you need more info.

@1602 1602 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.