Find subject_name according to subject_id in subject table

Hello everybody,

my question is probabely pretty simple but as a beginner and occasional programmer I am searching for the most straightforward and proper solution.

I have a form to create new Ruling. This form returns subject_id (subjects is one of my tables) and based on this id, I would like to find name of the subject saved in subjects table and use it as a part of file name of uploaded file.

Here is the corresponding part of add function of my RulingsController.php:

Please can anybody help me to find the easiest solution?

Maybe something like this: -

$subject = $this->Subjects->get($ruling->subject_id);
$subject_name = $subject->subject_name;

Thank you very much! That works.