[Catalyst] More natural access to model?

Paweł Tęcza ptecza at uw.edu.pl
Tue May 12 10:57:38 GMT 2009


Zbigniew Lukasiak pisze:
> 2009/5/12 Paweł Tęcza <ptecza at uw.edu.pl>:

>> So my question is: how can I modify my model to get the study details
>> in the following, more "natural" way?  Is it possibble at all?
>>
>> my @studies = $c->model('DB::Studies')->all;
>> foreach my $study in (@studies) {
>>    $study_name        = $study.study_datas.name        || '';
>>    $study_description = $study.study_datas.description || '';
>>    $study_program     = $study.study_datas.program     || '';
>>    $study_email       = $study.study_datas.email       || '';
>> }
>>
> 
> Hmm - there is something missing there - according to your description
> above $study.study_datas.program can not identify one value - but
> rather an array of values (one for each language) isn't that true?
> 
> You might also want to change the '.' to '->'.

Hi Zbyszek,

Thanks for your reply! Of course, you're absolutely right. I have to
choose one language when I get all study details via my model. Sorry for
confusing, but I rather wanted to show my problem than working snippet ;)

Do you know solution of that issue? Maybe I should define subroutines in
MyApp::Schema::ResultSet::Studies module for all type of data?

Have a nice day,

P.

PS. I still remember your and Dexter presentation titled "Modern Perl"
at the Faculty of Mathematics Informatics and Mechanics at the
University of Warsaw in February :D



More information about the Catalyst mailing list