Controllers instantiate the given or supposed/guessed model automatically. see lib/AkActionController; method: ->instantiateModelClass
With a given id in the url they do a find(id).
Simply add $this->album = [...] to your edit-action.
Arthur,
$this->album->track->load();
will load tracks on
$this->album->tracks
AkActionController::instantitiateModelClass instantiates models in controllers and makes them available under $this->.
If params['id'] is available, it will load the model named after the controller using that id.
Until now, it was not possible to define the options for the automatic finder in a simple way. I've just added the ability to define which options should be passed to the finder method by using the finder_options attribute like
class AlbumController extends ApplicationController{
var $finder_options = array('Album' => array('include' => 'tracks')); // Album case matters
// ....
}
Note: this only works on the trunk version.
Imagine you have a User model which is related to posts, videos, images, addresses, credit cards, invoices and so on. That is a common scenario and it is unlikely you want to instantiate all the associated models every time you load a user.
1 to 6 of 6