Monday, March 1, 2010

Searchable behavior on two models

I am using this behavior (http://code.google.com/p/searchable-
behaviour-for-cakephp/
) on two different models (User and Post).
Searchable is working fine when I add a new user and search for a
user. I manually populated a few rows of Post data and my search for
a post function works fine. However when I try to add a new post I get
the following errors.

Undefined index: User [APP/models/behaviors/searchable.php, line 77]
Invalid argument supplied for foreach() [APP/models/behaviors/
searchable.php, line 78] SQL Error: 1048: Column 'association_key'
cannot be null [CORE/cake/libs/model/datasources/dbo_source.php, line
525] Query: INSERT INTO `search_index` (`model`, `association_key`,
`data`, `modified`, `created`) VALUES ('User', NULL, '', '2010-02-28
12:04:11', '2010-02-28 12:04:11')

Query: INSERT INTO `search_index` (`model`, `association_key`, `data`,
`modified`, `created`) VALUES ('User', NULL, '', '2010-02-28
12:04:11', '2010-02-28 12:04:11')

Cannot modify header information - headers already sent by (output
started at /home/xxx/example.com/cake/basics.php:307) [CORE/cake/libs/
controller/controller.php, line 644]

So from what I can tell when I add a post something with the user
model is conflicting with my add posts function, as the Query stats
the model value is "user" and not post. I would expect to see the
query values start with the 'Post' model then the post id and then
some data.

Is there something I need to do when using this behavior on two
different models? Is there any reason that the behavior thinks I am
inserting User data when in fact I am inserting Post data?

Any help or suggestions would be appreciated.

Thanks.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: