⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Unable to locate the model you have specified: Grocery_crud_model



Hamed
  • profile picture
  • Member

Posted 04 June 2015 - 05:14 AM

Hello

This is my controller code:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Main extends CI_Controller {

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

		$this->load->database();
		$this->load->helper('url');
$this->load->model('grocery_crud_model');
		$this->load->library('grocery_CRUD');
		
	}

	public function _example_output($output = null)
	{
		$this->load->view('example.php',$output);
	}

	public function index()
	{
	   redirect('main/address');
	}
    public function address()
    {
        	   try{
			$crud = new grocery_CRUD();

			$crud->set_theme('datatables');
			$crud->set_table('data');
			$crud->set_subject('آدرس');
			$crud->required_fields('name','type','address');
            
            $crud->set_relation('type','groups','name');
            
			$output = $crud->render();

			$this->_example_output($output);

		}catch(Exception $e){
			show_error($e->getMessage().' --- '.$e->getTraceAsString());
		}
    }

}<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Main extends CI_Controller {

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

		$this->load->database();
		$this->load->helper('url');
$this->load->model('grocery_crud_model');
		$this->load->library('grocery_CRUD');
		
	}

	public function _example_output($output = null)
	{
		$this->load->view('example.php',$output);
	}

	public function index()
	{
	   redirect('main/address');
	}
    public function address()
    {
        	   try{
			$crud = new grocery_CRUD();

			$crud->set_theme('datatables');
			$crud->set_table('data');
			$crud->set_subject('آدرس');
			$crud->required_fields('name','type','address');
            
            $crud->set_relation('type','groups','name');
            
			$output = $crud->render();

			$this->_example_output($output);

		}catch(Exception $e){
			show_error($e->getMessage().' --- '.$e->getTraceAsString());
		}
    }

}

Now I get:

Unable to locate the model you have specified: Grocery_crud_model

 

 

How can I fix it?

 


Paul Savostin
  • profile picture
  • Member

Posted 04 June 2015 - 10:28 AM

This error I think means that not work this line $this->load->model('grocery_crud_model');

Check place your model

 


marcelodompieri
  • profile picture
  • Member

Posted 05 June 2015 - 02:21 AM

If you are using CodeIgniter 3.0, rename grocery_crud_model.php in model folder to Grocery_crud_model.php 

 

http://www.codeigniter.com/user_guide/installation/upgrade_300.html


ejay56
  • profile picture
  • Member

Posted 17 October 2015 - 09:12 AM

Hi there. I downloaded the latest code igniter and latest Grocery_crud, but  i have the same problem.

All the changes explained on link above changed on the latest version of grocery crud.

 

Everything works well on my local easyphp setup.But when i upload to the server, it giving me this error.

 

 

An uncaught Exception was encountered

Type: RuntimeException

Message: Unable to locate the model you have specified: Grocery_CRUD_Model

Filename: /home/site/public_html/traveldesk/crud/system/core/Loader.php

Line Number: 314

Backtrace:

File: /home/site/public_html/traveldesk/crud/application/libraries/Grocery_CRUD.php
Line: 484
Function: model

File: /home/site/public_html/traveldesk/crud/application/libraries/Grocery_CRUD.php
Line: 4425
Function: set_default_Model

File: /home/site/public_html/traveldesk/crud/application/libraries/Grocery_CRUD.php
Line: 4443
Function: pre_render

File: /home/site/public_html/traveldesk/crud/application/controllers/Examples.php
Line: 55
Function: render

File: /home/site/public_html/traveldesk/crud/index.php
Line: 292
Function: require_once


Paul Savostin
  • profile picture
  • Member

Posted 19 October 2015 - 23:21 PM

I found the solution! carefully check name of Grocery_CRUD_Model, they must be equal in filename and class name!


rostamiani
  • profile picture
  • Member

Posted 30 October 2015 - 14:31 PM

Solved!!

Set filename and class name as following:

 

Filename: Grocery_CRUD_Model.php

Classname: grocery_CRUD_Model


Massi Engin
  • profile picture
  • Member

Posted 07 April 2016 - 13:51 PM

i had the same problem the solution was to change filename from Grocery_CRUD_Model.php to grocery_CRUD_Model.php