title: Grails RestfulController Overriding an resource update
body: <p>So I'm having a little trouble when updating a resource in Grails. So here is my controller, in which I'm overriding some methods</p>
  
  <pre><code>@Override
  protected saveResource(resource) {
      if (request.post) {
          permissionsService.addPermission(resource.id, springSecurityService.getCurrentUser(), 'Outing')
      }
      resource.save(flush: true)
  }
  
  @Override
  protected updateResource(resource) {
      if (permissionsService.isAdmin()) {
          println 'doesnt print'
          saveResource(resource)
      } else if (permissionsService.canWrite('Outing', params.id, springSecurityService.getCurrentUser())) {
          println 'doesnt print'
          saveResource(resource)
      } else {
          println 'prints to console'
          response.status = 404
      }
  }
  </code></pre>
  
  <p>This is what the top of the controller looks like</p>
  
  <pre><code>import grails.converters.JSON
  import grails.rest.*
  
  class OutingController extends RestfulController {
  
      static responseFormats = ['json']
      OutingController() {
           super(Outing)
      }
  ...............
  }
  </code></pre>
  
  <p>My problem is that when I perform a PUT, for some reason the resource is still updated and saved. I can't figure out why because it never hits the saveResource or any other save function to my knowledge. I would like it to return with the status 404, but I could use some help with that. I'm basically adding permissions to the restful controller. Thanks for any help</p>
  
  <p>Here is the RestfulController if you'd like to look. <a href="https://github.com/grails/grails-core/blob/master/grails-plugin-rest/src/main/groovy/grails/rest/RestfulController.groovy" rel="nofollow">https://github.com/grails/grails-core/blob/master/grails-plugin-rest/src/main/groovy/grails/rest/RestfulController.groovy</a></p>