Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Scaffolding problem
#1

[eluser]zovar[/eluser]
Hi there, these are my first days coding with CI and I have a quick question.

When trying scaffolding I can only access the default page, but when I click on Add or View - I get a 404 error.

I have tried to search this forum for similar topics - i found loads of them. So i checked my config files, my controller file etc.

file: application/config/config.php
Code:
$config['base_url']    = "http://webz/";

file: application/config/routes.php
Code:
$route['default_controller'] = "notes";
$route['scaffolding_trigger'] = "scaff";

file: application/controllers/notes.php
Code:
function __construct()
    {
        parent::Controller();
        
        $this->load->scaffolding('notes');
    }

the address that i use to load scaffolding is http://webz/notes/scaff

Can you help me? Must be something simple, but I spend couple of hours already trying to figure it out...
#2

[eluser]jtkendall[/eluser]
Hi zovar, do you have an .htaccess file setup with mod_rewrite? I usually get 404's only if I've forgotten my .htaccess file.

You'll need the .htaccess file for clean URL's, if you don't have a .htaccess file, I've included the one I use below. Alternatively if you don't want to use clean URL's you can try going to http://webz/index.php/notes/scaff and see if it works for you.

Code:
Options +FollowSymLinks
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
    RewriteCond %{HTTP_HOST} ^www\.(.8)$
    RewriteRULE (.*) http://%1/$1 [R=301,L]
</IfModule>
<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>
#3

[eluser]zovar[/eluser]
Thank you, but no, it didn't work.

I have set up mod_rewrite, and it works fine (otherwise I wouldn't be able to access any controller without an index.php in the address?..)

Do you have any other thoughts?

What seems weird to me is that the edit link from the scaffolding "homepage" goes to http://webz/edit/1 but not to http://webz/notes/edit/1 (although I tried this address and it didn't work)?

Should a controller be included in this address?
#4

[eluser]zovar[/eluser]
SOLVED

After comparing autoload.php files from fresh and old installation line by line, I have found the problem. Don’t autoload ‘uri’ library! It load automatically and if you load it for the second time - it will brake itself.

I think the official tutorial still contains an advice to load it manually though…




Theme © iAndrew 2016 - Forum software by © MyBB