title: SailsJS accessing a service from a controller
body: <p>I am trying to create a service in sailsjs so I can access some business logic from within multiple controllers, I've stumbled upon a number of issues... The service is an 'Action log' I hope to log data about specific api calls to the database via a model.</p>
  
  <p>The file structure I have:</p>
  
  <pre><code>api/services/actionService.js - the service to receive data from controller and log to model
  api/models/Action.js - functioning model to store logged actions
  api/controllers/ActionController.js - functioning controller to respond to get requests for the action model
  api/controllers/AnotherController.js - I wish to access the actionService from here to input data
  </code></pre>
  
  <ol>
  <li><p>I am unsure how to reference the service from AnotherController.js; according to the <a href="https://github.com/balderdashy/sails-docs/blob/0.10/services.md" rel="nofollow">sails docs</a> I should be able to call <code>ActionService(data)</code> but I get an <code>ActionService is not defined</code> error. Is there something I need to do to load this dependency in the controller?</p></li>
  <li><p>Am I able to reference a model from within the service? At the moment I have something like <code>Action.create(action)...</code> in the service. This hasn't caused problems yet as I haven't got passed the first issue but wondering whether I also need to load this as a dependency in the service?</p></li>
  </ol>
  
  <p>I'm new to implementing services in sailsjs, any help is appreciated.</p>