> -----Original Message----- > From: Adam Witney [mailto:[email protected]] > Sent: Monday, March 16, 2009 3:00 PM > To: The elegant MVC web framework > Subject: Re: [Catalyst] Catalyst and ExtJS > > > > > No, don't do that! > > > > Use $row->get_columns which returns a hash of the column data! > > Accessing internal methods is bad, accessing internal hash keys is > > doubleplusungood. If you find yourself doing that, go read some > > documentation. If you haven't figured it out without doing that, > > submit a patch for a proper method! > > > > Here's the pod: > > http://search.cpan.org/~ribasushi/DBIx-Class- > 0.08012/lib/DBIx/Class/Row.pm#get_columns > > > > Also, you can use the HashRefInflator which works -fantastic- for > > JSON views: > > > > The code is very simple: > > > > my $rs = $c->model('DB::Books'); > > $rs->resultclass('DBIx::Class::HashRefInflator'); > > $c->stash->{books} = [ $rs->all ]; > > > > You can read about that here: > > http://search.cpan.org/~ash/DBIx-Class- > 0.08010/lib/DBIx/Class/ResultClass/HashRefInflator.pm > > excellent, thanks guys, with minor modifications both those approaches > work: > > $c->stash->{books} = [map { $_->get_columns } $c- > >model('DB::Books')->all]; > > OR: > > my $rs = $c->model('DB::Books'); > $rs->result_class('DBIx::Class::ResultClass::HashRefInflator'); > $c->stash->{books} = [ $rs->all ]; > > thanks again for your help > > adam
You only want to present the data you need to ExtJS, you were stuffing the whole dbic resultset object into the JSON ;). _______________________________________________ List: [email protected] Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/
