trailsjs / generator-trails-old

:package: Trails Generator.
Other
6 stars 8 forks source link

Name of create policy is not consistant #65

Closed KNTH01 closed 8 years ago

KNTH01 commented 8 years ago

Hi,

When I create a Policy with yo : yo trails:policy Auth or yo trails:policy AuthPolicy, it's create me a file named api/policies/Auth.js with AuthPolicy class. In api/policies/index.js, I have exports.Auth = require('./Auth').

So to use my policy :

// config/policies.js
module.exports = {
  ExampleController: {
    test: [ 'Auth.test' ] // Should be AuthPolicy.test
  }
}

But in the example (readme.md) there is :

// config/policies.js
module.exports = {
  ExampleController: {
    test: [ 'ExamplePolicy.test' ]
  }
}

I find this is not consistent regarding to the controllers and services system which add Controller and Service prefix to the new generated controller or service. So when I generate a policy, I should have AuthPolicy.js instead of Auth.js isn't it ?

The same note applies to models too.

konstantinzolotarev commented 8 years ago

Fix here: https://github.com/trailsjs/generator-util/pull/3

KNTH01 commented 8 years ago

Thanks for the fix @konstantinzolotarev :) I had mentionned the models too :)

jaumard commented 8 years ago

@KevinNTH models are working like they should, they are native to ORM so we don't want to add Model suffix at the end (because most ORM will also add it into the table name) Thanks @konstantinzolotarev ! Waiting travisCI results and I merge it :D