Controllers and Models in Codeigniter – Choose names wisely

Short version: Make sure you don’t name your controllers and models the same when working with Codeigniter. Probably good practice with any programming, but I just lost 15min. trying to figure out why I got a method not found error on a model when the controller calling it had the same class name. . . oops.

I had a model named User, a core controller class that called helper class that used that model, and a controller named User. On that controller, I got 500 errors calling a method from my User model. It worked fine on all my other controllers. I removed that controller and used a profile controller I had for all user pages, and it worked like a charm.

Leave a Reply

Your email address will not be published. Required fields are marked *