Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter 3 Unable to locate the model you have specified

I'm getting this error:

Unable to locate the model you have specified: Users_model

CodeIgniter is version 3. The filename is Users_model.php. It is located at application\models and it goes like this:

defined('BASEPATH') OR exit('No direct script access allowed');
class Users_model extends CI_Model {

    public function __construct()
    {
        parent::__construct();
    }

[...]
}

I am calling it from a controller like this:

$this->load->model('users_model');

Interestingly enough, it works on a local mongoose server, but not when I deploy it to a heroku server.

like image 886
sthiago Avatar asked May 24 '15 06:05

sthiago


2 Answers

Your git may be configured to ignore case changes in file names. The effect of this is: any local changes to a filename of a file that has already been deployed (i.e. is only being modified) are not mirrored on the remote repository (heroku).

For example, if you first deployed a file with the name users_model.php all lowercase. Even if you change the local version of the file to Users_model.php with the 'U' capitalized, the remote won't mirror this change.

How to solve it: to tell git to update filename case changes, run the following command:

git config core.ignorecase false

Thanks to @Kamram for making me figure this out and @FeanDoe for suggesting that I answer the question.

like image 155
sthiago Avatar answered Oct 18 '22 16:10

sthiago


Try this.

  1. In your model file name should be users_model.php.
  2. inside model it should be (Users_Model)

    class Users_Model extends CI_Model{}.

  3. When you calling use $this->load->model('Users_Model');

like image 5
Abdulla Nilam Avatar answered Oct 18 '22 16:10

Abdulla Nilam