I am looking to load values from my database in my /app/Config/routes.php configuration file.
At the top I am using: App::uses('Option', 'Model');
And I am calling my find in my class: $this->Option->find('all');
Am I missing something?
I am looking to load values from my database in my /app/Config/routes.php configuration file.
At the top I am using: App::uses('Option', 'Model');
And I am calling my find in my class: $this->Option->find('all');
Am I missing something?
I wouldn't put any database queries in Routes. It's not the place for them (separation of concerns etc). It will also slow down every request and the routes shouldn't be changing all that frequently.
What I've done is to create a routes file in app/tmp/cache every time a database route is created/updated (your code will be different but this is how I do it).
In your route model:
Call rebuildCache() from your route model afterSave():
Simply include the file in Routes.php:
I think you have to instantiate the model before you use it: