CodeIgniter Forums
Models not being located - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Models not being located (/thread-25167.html)

Pages: 1 2


Models not being located - El Forum - 12-03-2009

[eluser]moopa[/eluser]
Hi all.

I am trying to deploy my app to a remote server that does not have an ANAME associated with it right now. (e.g. http://webserver.com/~myuseraccount)

Any page that references my models does not work (i get Unable to locate the model you have specified: videodatasource).

I have correctly setup $config['base_url'] = http://webserver.com/~myuseraccount

Any info appreciated how to resolve this.

Thanks,

Moopa


Models not being located - El Forum - 12-03-2009

[eluser]jedd[/eluser]
[quote author="moopa" date="1259862181"]
Any page that references my models does not work (i get Unable to locate the model you have specified: videodatasource).
[/quote]

[url="http://codeigniter.com/wiki/How_to_ask_a_good_question/"]We have a guide on how to ask better questions.[/url]

It's possibly a simple case-sensitivity thing. You've declined to say what type of OS you're on, and what you're moving to, but I assume Microsoft --> GNU/Linux.

The [url="/wiki/FAQ"]FAQ[/url] contains a couple of hints on things to look out for during migration. It would be impolite to ask a question already answered in the FAQ.

You've declined to show the class instantiation line of your model, or how you're calling them from your controller, or what the filename is of the model itself.

Unsurprisingly, you need to provide more information in order to get more help.


Models not being located - El Forum - 12-03-2009

[eluser]moopa[/eluser]
[quote author="jedd" date="1259873945"][quote author="moopa" date="1259862181"]
Any page that references my models does not work (i get Unable to locate the model you have specified: videodatasource).
[/quote]

[url="http://codeigniter.com/wiki/How_to_ask_a_good_question/"]We have a guide on how to ask better questions.[/url]

It's possibly a simple case-sensitivity thing. You've declined to say what type of OS you're on, and what you're moving to, but I assume Microsoft --> GNU/Linux.

The [url="/wiki/FAQ"]FAQ[/url] contains a couple of hints on things to look out for during migration. It would be impolite to ask a question already answered in the FAQ.

You've declined to show the class instantiation line of your model, or how you're calling them from your controller, or what the filename is of the model itself.

Unsurprisingly, you need to provide more information in order to get more help.[/quote]

I grant you that my first post was a little vague. Hopefully my points below will help clarify the situation a little.

* My OS is OSX running Apache.
* Deployment server is Linux shared hosting with cpanel / apache.
* The issue is most definitely not case sensitivity.

Since my previous post, I have commented out all DAL calls to the models and got the site displaying.

The problem appears to be how the shared hosting home directory is setup. I am (obviously) not well versed on setting up apache and I want to know if I can change how my home directory is perceived as references to images, css and js files that start like so:-

Code:
background:transparent url(/common/img/myjpg.jpg) left top no-repeat;
src="/common/css/global.css";

These work fine on my local instance of Apache with one website but the path is incorrectly mapped on the shared host (presumably due to virtual directory mapping?)

On the shared host I have to use "../".

Is there a rewrite rule or another solution I can set on the root of the user folder to stop this being an issue? I feel that this is the cause of my model reference errors also.

Thanks


Models not being located - El Forum - 12-03-2009

[eluser]jedd[/eluser]
If controllers are working, then models tend to just work - I can't think of anything obvious, along the lines of pathing, that would give you this problem.

You've said your config settings are accurate - though the code you showed in your first post:
Quote:I have correctly setup $config[‘base_url’] = http://webserver.com/~myuseraccount

.. is perhaps sanguine, given the advice given in the config.php file immediately above that setting, viz:
Code:
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:

You can see why my 'trust your accuracy' cup does not runneth overeth.


[quote author="jedd" date="1259873945"]
[quote author="moopa" date="1259862181"]
Any page that references my models does not work (i get Unable to locate the model you have specified: videodatasource).
[/quote]
You've declined to show the class instantiation line of your model, or how you're calling them from your controller, or what the filename is of the model itself.
[/quote]

Humour me - show me the filename, the 'class ... extends' line from a failing Model, and a line in your Controller that calls the Model. You may want to read up on the Model naming standards in the user guide first, though in a sense that would be cheating.


Models not being located - El Forum - 12-03-2009

[eluser]moopa[/eluser]
[quote author="jedd" date="1259877906"]
You can see why my 'trust your accuracy' cup does not runneth overeth.
[/quote]

I'm sure you can probably see that my url was an example to provide a level of anonymity for my client... Rest assured that the url is correct and has the slash.

[quote author="jedd" date="1259873945"]
You've declined to show the class instantiation line of your model, or how you're calling them from your controller, or what the filename is of the model itself.

Humour me - show me the filename, the 'class ... extends' line from a failing Model, and a line in your Controller that calls the Model. You may want to read up on the Model naming standards in the user guide first, though in a sense that would be cheating.[/quote]
[/quote]

No models work. Looking at the logs, everything else (including my own helper libraries) work fine.

For the sake of clarify, here is the declaration of a model:-

Code:
<?php
class ImageDataSource extends Model {
    
    function ImageDataSource()
    {
        parent::Model();
    }
?>

and here is an example in the controller. Once again, the entire application works fine on my dev machine...

Code:
// LOAD DAL
        $this->load->model('ImageDataSource');
        
        // LOAD SESSION LIBRARY AND CHECK IF THE USER HAS AN ALBUM IN SESSION
        $this->load->library('session');
        
// More code...

$current_imagealbum = $this->ImageDataSource->createAlbum($album_title,1,userid(),$mysqldate);

As stated previously, I believe the issue is with path mapping on the shared hosting. Do you have an understanding of how this is altered so that I can reference images with src="/common/img.jpg" as oppose to src="../common/img.jpg"

Thanks


Models not being located - El Forum - 12-03-2009

[eluser]jedd[/eluser]
[quote author="moopa" date="1259878676"]
I'm sure you can probably see that my url was an example to provide a level of anonymity for my client... Rest assured that the url is correct and has the slash.
[/quote]

I am not interested in who your client is - xxxx it out for all I care - but how can I assume that when you post a URL without a required trailing slash, that you've only removed it for the sake of anonymity?

Filename still not shown. Still can't think of anything that will, as you say, answer the question of why helpers, libraries and controllers work, but models don't. Hence I'm extra keen to rule out a nomenclature issue.

Given that:
a) your naming doesn't align with that described in the user guide, and
b) you're going from a generally case-insensitive file system to a case-sensitive one

.. then perhaps you'd humour me slightly more and try making a few temporary changes.

Read through the [url="/user_guide/general/models.html"]Models[/url] page in the guide, and change one of your models to fit the restrictions described, such as:
Quote:From user guide:

Where Model_name is the name of your class. Class names must have the first letter capitalized with the rest of the name lowercase.
...
The file name will be a lower case version of your class name. For example, if your class is this:
...
$this->load->model('Model_name');
...
$this->Model_name->function();



Models not being located - El Forum - 12-03-2009

[eluser]jedd[/eluser]
[quote author="moopa" date="1259878676"]
As stated previously, I believe the issue is with path mapping on the shared hosting. Do you have an understanding of how this is altered so that I can reference images with src="/common/img.jpg" as oppose to src="../common/img.jpg"
[/quote]

Oh, and you probably shouldn't be referencing images as either ../common or /common. This is why the base_url is defined in the config.php in the first place, so you can do stuff like this in your views:
Code:
<img src="&lt;?php echo base_url(); ?&gt;common/img.jpg">

If you're still having your earlier problem, can you crank up the logging so you can see what file (including the path) it's trying to open - that will give a bit more insight.


Models not being located - El Forum - 12-03-2009

[eluser]NateL[/eluser]
[quote author="moopa" date="1259862181"]
I have correctly setup $config['base_url'] = http://webserver.com/~myuseraccount
[/quote]

This may seem silly - but it could cause problems.

Does it look like this?
Code:
$config['base_url'] = http://webserver.com/~myuseraccount

or this?
Code:
$config['base_url'] = "http://webserver.com/~myuseraccount/";



Models not being located - El Forum - 12-03-2009

[eluser]moopa[/eluser]
Thanks everyone for your responses.
It turned out to be the shared hosting.

After a bit of playing with paths, I realised that I could correctly reference my images like so:-

Code:
/~myusername/common/img/myimg.jpg

When I contacted the host, they said this was most likely down to the lack of on ANAME on the account. I quickly set one and the web root became the correct root for application Smile

Behind the scenes, I am guessing that once an ANAME is in place, Apache configures the public_html folder to become the correct root, whereas previous to this, root we deemed to be /~myusername/

Cheers,

Moopa


Models not being located - El Forum - 12-03-2009

[eluser]jedd[/eluser]
I'm bewildered.

How did you get from saying that everything apart from models worked:

[quote author="moopa" date="1259878676"]
No models work. Looking at the logs, everything else (including my own helper libraries) work fine.
[/quote]

To saying that you've resolved the image loading problem:
[quote author="moopa" date="1259900492"]
It turned out to be the shared hosting.
...
Code:
/~myusername/common/img/myimg.jpg
[/quote]

I think I must have missed something in the middle.

Can you clarify how the models - the only thing originally not working - started to work once you had an ANAME entry?