Add a custom method in a Model using CFWHEELS

86 Views Asked by At

I am trying to add a custom method on one of my CFWheels Model but I am not able to do this. I have been reading the documentation but still not found an answer.

User.cfc

component extends="Component" {
    ...
    function getCustomSearch(){
        ...
    }
    ...
}

I want to change:

model("users").findAll(...)

To

model("users").getCustomSearch(...)

In order to refactor some function.

Is this possible? In that case, what I am doing wrong?

Thank you for your attention.

Regards.

2

There are 2 best solutions below

0
Neokoenig On BEST ANSWER

It will need to be model('user') not users; Wheels looks for the singular variant to match the models/User.cfc file.

0
Rodrigo R. On

I have left my computer and when I came back it was working. Dan Roberts was right, it's necessary to reload.

Thanks to all for the help!