Andy Kuo
2006-Sep-01 05:05 UTC
[Ferret-talk] Ferret/acts_as_ferret don''t seem to be doing anything
I''m having an odd problem with Ferret 0.9.5 and acts_as_ferret 0.2.3, on RedHat Linux Enterprise 4. All of my find_by_contents calls return 0 results. When I try Foo.rebuild_index via the console, it returns nil. This is happening on my production machine, during deployment of my app. Everything works perfectly on my development machine (Windows). I have no idea where to start debugging this. Am I missing something obvious? Any help would be greatly appreciated. Thanks, Andy -- Posted via http://www.ruby-forum.com/.
Jens Kraemer
2006-Sep-01 08:26 UTC
[Ferret-talk] Ferret/acts_as_ferret don''t seem to be doing anything
On Fri, Sep 01, 2006 at 07:05:31AM +0200, Andy Kuo wrote:> I''m having an odd problem with Ferret 0.9.5 and acts_as_ferret 0.2.3, on > RedHat Linux Enterprise 4. > > All of my find_by_contents calls return 0 results. When I try > Foo.rebuild_index via the console, it returns nil.Does anything show up in the log file when you do this ? A possible problem might be missing write permissions to your RAILS_ROOT, though I think this should result in an error. 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
Andy Kuo
2006-Sep-01 12:16 UTC
[Ferret-talk] Ferret/acts_as_ferret don''t seem to be doing anything
> > Does anything show up in the log file when you do this ? A possible > problem might be missing write permissions to your RAILS_ROOT, though > I think this should result in an error. >Thanks for the tip, Jens. I think I figured this out. It turns out it was two separate problems, for those who are interested. 1. My find_by_contents calls are wrapped in a with_scope(:include). find_by_contents has a line conditions = [ "id in (?)", id_array ] During development, this was causing a MySQL "ambiguous column id" error, because the tables I was joining each contained an id column. I had changed the line to conditions = [ "#{self.name.pluralize}.id in (?)", id_array ] which worked fine on my Windows box. On the Linux box, MySQL was complaining about an "unknown column Foos.id". I hadn''t realized that MySQL on Linux was case-sensitive, whereas Windows is not, so I changed the line to conditions = [ "#{self.name.downcase.pluralize}.id in (?)", id_array ] 2. I had defined a WhiteSpaceAnalyzer (different from the one defined in Ferret) in my environment.rb file, and was calling it in acts_as_ferret. For some reason, though, the analyzer being used was the WhiteSpaceAnalyzer defined in Ferret, instead of mine. My guess as to why this is happening is because of the order in which environment.rb and ferret are loaded? I''m not even sure redefining it in environment.rb is the right way to do it, so I''d be happy if someone knew what the right way of doing this is. My workaround was just to rename my analyzer. -- Posted via http://www.ruby-forum.com/.
Jens Kraemer
2006-Sep-01 12:26 UTC
[Ferret-talk] Ferret/acts_as_ferret don''t seem to be doing anything
Hi! On Fri, Sep 01, 2006 at 02:16:17PM +0200, Andy Kuo wrote: [..]> > On the Linux box, MySQL was complaining about an "unknown column > Foos.id". I hadn''t realized that MySQL on Linux was case-sensitive, > whereas Windows is not, so I changed the line to > > conditions = [ "#{self.name.downcase.pluralize}.id in (?)", id_array ]Even better would be "#{self.table_name}.id in (?)", because that works in case you don''t use the standard naming scheme for your tables, too. Recent versions of aaf contain this fix.> 2. I had defined a WhiteSpaceAnalyzer (different from the one defined in > Ferret) in my environment.rb file, and was calling it in acts_as_ferret. > For some reason, though, the analyzer being used was the > WhiteSpaceAnalyzer defined in Ferret, instead of mine. My guess as to > why this is happening is because of the order in which environment.rb > and ferret are loaded? I''m not even sure redefining it in > environment.rb is the right way to do it, so I''d be happy if someone > knew what the right way of doing this is. My workaround was just to > rename my analyzer.where you declare you custom Analyzer class shouldn''t be that important, I''d personally place it in lib/ and require that file in environment.rb. To avoid problems you should indeed choose a unique class name, though I can''t imagine where the problem was in that special case. 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
Seemingly Similar Threads
- cannot use acts_as_ferret on legacy tables or tables with a
- acts_as_ferret : cannot use a customized Analyzer (as indicated in the AdvancedUsageNotes)
- acts_as_ferret 0.2.2
- Multiple Models w/ acts_as_ferret
- NameError uninitialized constant Ferret::Index::FieldInfos