Express cannot PUT/DELETE method. What is going wrong?

Update

As Jonathan Lonowski pointed out PUT can also be used, so you can ignore my old answer. Getting Cannot PUT or Cannot POST errors, means your callback is not executing successfully. My guess is that Users.update is failing, which is why it cannot POST or PUT. Can you check it.

Old answer

Try changing this line

app.put('/users/:name', function(req, res) {

to

app.post('/users/:name', function(req, res) {

since you are trying to submit the form


Is the <form> you listed in a view or a static file under __dirname + "/public"?

Within a static file, the #{user.name} probably isn't being replaced with the user's name and will be treated as a URL Fragment.

The <form> will actually submit to /users/ rather than /users/:name since that's the path:

console.log(url.parse('/users/#{user.name}'));

{ hash: '#{user.name}',
  pathname: '/users/',
  path: '/users/',
  href: '/users/#{user.name}' }

The <form> should be generated from a view if it isn't since the action needs to be dynamic and data-driven. With Jade and assuming user is a member of locals, that would be:

form(method='POST', action='/users/' + user.name)
  input(type='hidden', name='_method', value='PUT')