[Catalyst] putting an object in the stash
Matt Lawrence
matt.lawrence at ymogen.net
Tue Mar 13 16:24:46 GMT 2007
Bogdan Lucaciu wrote:
> On Tuesday 13 March 2007 15:06, Octavian Rasnita wrote:
>
>>> my $model = $c->model("Database::Table");
>>> foreach my $column (@{$model->columns}) {
>>> $column =~ s{me\.}{}; # strip the prefix DBIC adds
>>> $c->stash->{$column} = $obj->$column;
>>> }
>>>
>> I have tried that, but it gave the following error:
>>
>> Can't locate object method "columns" via package "DBIx::Class::ResultSet
>>
>> What am I doing wrong?
>>
>
>
> it's $resultset->result_source->columns
>
>
Alternatively, get_columns will return a hash (not a reference!) of the
current row.
$c->stash->{obj }= { $row->get_columns };
Note that this hash contains uninflated values, if you want column
inflation you'll need to loop.
Matt
More information about the Catalyst
mailing list