David Smalley
2006-Aug-19 08:40 UTC
[Ferret-talk] acts_as_ferret causing strange behaviour
I posted this issue as a bug on the acts_as_ferret trac (http://projects.jkraemer.net/acts_as_ferret/ticket/36) but need to get this working asap. so hopefully someone can point me in the right direction. To try and sum this up in better terms than I used in the original bug report, the problem I am experiencing seems to be related to the fact I am using inheritance in my controllers. I have an admin area and a public area that for DRY purposes use inheritance to pass down acl and authentication filters. Having installed ferret and acts_as_ferret I am able to add it to models and build indexes from the console, I can then search the index no problem. Once I start using the app from a web browser, I keep getting name errors on all the models that have acts_as_ferret added to them. The error tells me that the model name (e.g. Page) is an uninitialized constant. In addition the error message also tells me the problem occured when attempting to load file e.g. /admin/page.rb All my models are stored in the /models/ directory, however the controller calling the model is inherited from a controller called AdminAreaController within /controllers/admin/pages_controller.rb So, why when I add acts_as_ferret does rails try to look for my model in /model/admin if the controller is in /controllers/admin, but if i use the console then everything is fine? Any ideas, I''m a bit stumped... -- Posted via http://www.ruby-forum.com/.
Hi David, this sounds strange. I''ll try to reproduce this scenario here and get back to you. jens On Sat, Aug 19, 2006 at 10:40:50AM +0200, David Smalley wrote:> I posted this issue as a bug on the acts_as_ferret trac > (http://projects.jkraemer.net/acts_as_ferret/ticket/36) but need to get > this working asap. so hopefully someone can point me in the right > direction. > > To try and sum this up in better terms than I used in the original bug > report, the problem I am experiencing seems to be related to the fact I > am using inheritance in my controllers. > > I have an admin area and a public area that for DRY purposes use > inheritance to pass down acl and authentication filters. Having > installed ferret and acts_as_ferret I am able to add it to models and > build indexes from the console, I can then search the index no problem. > > Once I start using the app from a web browser, I keep getting name > errors on all the models that have acts_as_ferret added to them. The > error tells me that the model name (e.g. Page) is an uninitialized > constant. In addition the error message also tells me the problem > occured when attempting to load file e.g. /admin/page.rb > > All my models are stored in the /models/ directory, however the > controller calling the model is inherited from a controller called > AdminAreaController within /controllers/admin/pages_controller.rb > > So, why when I add acts_as_ferret does rails try to look for my model in > /model/admin if the controller is in /controllers/admin, but if i use > the console then everything is fine? > > Any ideas, I''m a bit stumped... > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ferret-talk mailing list > Ferret-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/ferret-talk-- 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
David Smalley
2006-Aug-21 22:44 UTC
[Ferret-talk] acts_as_ferret causing strange behaviour
Jens Kraemer wrote:> Hi David, > > this sounds strange. I''ll try to reproduce this scenario here and get > back to you.Hi Jens, Thanks, let me know if I can supply any-more information to aid you in tracking this down. David -- Posted via http://www.ruby-forum.com/.
Hi David, I tried to reproduce the problem, but no luck. Here''s what I have now: app/controllers/admin_area_controller.rb: class AdminAreaController < ApplicationController end app/controllers/admin/backend_controller.rb: class Admin::BackendController < AdminAreaController def search # search method using Content.find_by_contents ... end end app/models/content.rb class Content acts_as_ferret ... end Search using the backend_controller works fine, which means the Content class is indeed found. You can have a look at the code in the aaf test suite at http://projects.jkraemer.net/acts_as_ferret/browser/trunk/demo or via svn: svn://projects.jkraemer.net/acts_as_ferret/trunk/demo Am I missing something ? Jens On Tue, Aug 22, 2006 at 12:05:40AM +0200, Jens Kraemer wrote:> Hi David, > > this sounds strange. I''ll try to reproduce this scenario here and get > back to you. > > jens > > On Sat, Aug 19, 2006 at 10:40:50AM +0200, David Smalley wrote: > > I posted this issue as a bug on the acts_as_ferret trac > > (http://projects.jkraemer.net/acts_as_ferret/ticket/36) but need to get > > this working asap. so hopefully someone can point me in the right > > direction. > > > > To try and sum this up in better terms than I used in the original bug > > report, the problem I am experiencing seems to be related to the fact I > > am using inheritance in my controllers. > > > > I have an admin area and a public area that for DRY purposes use > > inheritance to pass down acl and authentication filters. Having > > installed ferret and acts_as_ferret I am able to add it to models and > > build indexes from the console, I can then search the index no problem. > > > > Once I start using the app from a web browser, I keep getting name > > errors on all the models that have acts_as_ferret added to them. The > > error tells me that the model name (e.g. Page) is an uninitialized > > constant. In addition the error message also tells me the problem > > occured when attempting to load file e.g. /admin/page.rb > > > > All my models are stored in the /models/ directory, however the > > controller calling the model is inherited from a controller called > > AdminAreaController within /controllers/admin/pages_controller.rb > > > > So, why when I add acts_as_ferret does rails try to look for my model in > > /model/admin if the controller is in /controllers/admin, but if i use > > the console then everything is fine? > > > > Any ideas, I''m a bit stumped... > > > > -- > > Posted via http://www.ruby-forum.com/. > > _______________________________________________ > > Ferret-talk mailing list > > Ferret-talk at rubyforge.org > > http://rubyforge.org/mailman/listinfo/ferret-talk > > -- > 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 > _______________________________________________ > Ferret-talk mailing list > Ferret-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/ferret-talk-- 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