Hi Adam,
I have these two controllers whose code differs chiefly in respect of the
table being accessed.
The two tables (Affiliation and People) have a reciprocatory 'has_many' /
'belongs_to' relationship. While the affiliation_data sub works, the
people_data sub doesn't. The error message I'm getting for the people_data
sub inclines me to think that the 'allow_blessed' / 'convert_blessed'
features have to be enabled when a table has a 'belongs_to' relationship. I
don't know how to do that.
=head2 people_data
=cut
sub people_data : Local {
my ( $self, $c ) = @_;
my $rs = $c->model( 'AdventAjaxGrid2DB::People' );
my @people = ();
while ( my $person = $rs->next ) {
push( @people, {
id => $person->id,
name => $person->name,
affiliation_id => $person->affiliation_id,
} );
}
$c->stash->{ 'people_stash' } = \...@people;
$c->detach( $c->view( 'JSON' ) );
}
=head2 affiliation_data
=cut
sub affiliation_data : Local {
my ($self, $c) = @_;
my $rs = $c->model('AdventAjaxGrid2DB::Affiliation');
my @affiliations = ();
while (my $affiliation = $rs->next) {
push(@affiliations, {
affiliation_id => $affiliation->affiliation_id,
affiliation_name => $affiliation->affiliation_name
});
}
$c->stash->{'affiliation_stash'} = \...@affiliations;
$c->detach($c->view('JSON'));
}
On Thu, Apr 30, 2009 at 10:04 PM, Adam Witney <[email protected]> wrote:
> The error I get is :
>> "[error] Caught exception in AdventAjaxGrid2::View::JSON->process
>> "encountered object
>> 'AdventAjaxGrid2::Model::AdventAjaxGrid2DB::Affiliation=HASH(0x91b8270)',
>> but neither allow_blessed nor convert_blessed settings are enabled at
>> /usr/local/share/perl/5.8.8/JSON/Any.pm line 426."
>>
>> I couldn't figure out how to enable those settings from the JSON-Any write
>> up on CPAN. How is that to be done?
>>
>
> from my limited experience, this seems to come up when you are not sending
> proper JSON to the JSON view. Check the code before the line:
>
> $c->detach( $c->view( 'JSON' ) );
>
> to see what you are sending it (The error suggests you are pushing an
> object to it, in the calendar example he sends a reference to an array of
> hashes).
>
> HTH
>
> adam
>
>
> _______________________________________________
> 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/
>
_______________________________________________
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/