Chris Williams
2006-Nov-28 08:03 UTC
[Ferret-talk] find_by_contents never finds anything on my model
Hi, Let me preface by saying I am very new to ferret and aaf. Anyhow, I''m using the aaf plugin on a model named Book. This model isnt a typical rails model in the fact that it doesnt have an "id" column as its primary key but instead has a string column named ISBN that is used as the primary key. When I try to search for anything in the model using find_by_contents it never finds anything. Trying to troubleshoot, I added an id column in my model as an integer and made it auto increment. Once I added this, added my sample data back in, and rebuilt my index, I noticed that I could search all of a sudden using find_by_contents. I changed it back again, and then my searches had no results. I was wondering if there is anything to get it to work without having to add an id field to my model? Many thanks for your help in advance! -Chris -- Posted via http://www.ruby-forum.com/.
Jens Kraemer
2006-Nov-28 10:21 UTC
[Ferret-talk] [AaF] find_by_contents never finds anything on my model
On Tue, Nov 28, 2006 at 09:03:20AM +0100, Chris Williams wrote:> Hi, > Let me preface by saying I am very new to ferret and aaf. > > Anyhow, I''m using the aaf plugin on a model named Book. This model isnt > a typical rails model in the fact that it doesnt have an "id" column as > its primary key but instead has a string column named ISBN that is used > as the primary key. When I try to search for anything in the model > using find_by_contents it never finds anything. Trying to troubleshoot, > I added an id column in my model as an integer and made it auto > increment. Once I added this, added my sample data back in, and rebuilt > my index, I noticed that I could search all of a sudden using > find_by_contents. I changed it back again, and then my searches had no > results. I was wondering if there is anything to get it to work without > having to add an id field to my model?This should be possible, but not without modifying aaf. Aaf relies on your model having an ''id'' attribute in several places, if you changed these places to use ''isbn'' instead this should work. Maybe one even could solve this in a more generic way by getting the information what the actual primary key of the table is from active record. Anyway, the easiest way seems to rename your isbn column to ''id'' would be the easiest way ;-) cheers, Jens -- webit! Gesellschaft f?r neue Medien mbH www.webit.de Dipl.-Wirtschaftsingenieur Jens Kr?mer kraemer at webit.de Schnorrstra?e 76 Tel +49 351 46766 0 D-01069 Dresden Fax +49 351 46766 66