ms
2009-Sep-03 23:21 UTC
Strange NoMethodErrors in production mode, I just don''t know what to do.
Hi, thanks for reading. Since hours, I am facing a problem and it seems that I am not able to solve it. Let''s say, I''ve got a model called "AnnotationType". This model has got a method called "foobar(x)". It''s just so simple. I can access this method in my unit tests, in the console (all modes), but if I start the server in production mode and try to access this method from within a view, it can just be found on the first request. Afterwards, this method isn''t found anymore: undefined method `foobar'' for #<AnnotationType:0x7f7be4728870> vendor/rails/activerecord/lib/active_record/attribute_methods.rb: 256:in `method_missing'' vendor/rails/activerecord/lib/active_record/associations/ association_proxy.rb:177:in `send'' vendor/rails/activerecord/lib/active_record/associations/ association_proxy.rb:177:in `method_missing'' lib/ui/user_interface_renderer.rb:114:in `create_common_display_element'' ... As you can see, my user interface renderer calls this method, but it can''t be found. Of course, it is not the name of an association proxy. This explains the above lines. As I said, and yes, I swear: this method exists! :) I am really thankful for any hint! Cheers, ms
Emanuele Tozzato
2009-Sep-03 23:34 UTC
Re: Strange NoMethodErrors in production mode, I just don''t know what to do.
make sure the production application was restarted correctly! (it happened to me.. ) On Thu, Sep 3, 2009 at 4:21 PM, ms <ms-cGBD8117FJM@public.gmane.org> wrote:> > Hi, > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ms
2009-Sep-03 23:45 UTC
Re: Strange NoMethodErrors in production mode, I just don''t know what to do.
Hi, thanks for your device, but I also tried this. I restarted my whole machine to be sure. But it does not work. I found out something new: If I include this method from a module, it can be found. But all the other methods are not found - also the association proxies! It seems to me, that rails just instantiates a raw ActiveRecord object just with the name of my model. The list of methods you get with ".methods()" only contains the default inherited methods. I am absolutely confused. Maybe another idea? Thank you all. On 4 Sep., 01:34, Emanuele Tozzato <etozz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> make sure the production application was restarted correctly! > (it happened to me.. ) > > > > On Thu, Sep 3, 2009 at 4:21 PM, ms <m...-cGBD8117FJM@public.gmane.org> wrote: > > > Hi,
Colin Law
2009-Sep-04 07:46 UTC
Re: Strange NoMethodErrors in production mode, I just don''t know what to do.
2009/9/4 ms <ms-cGBD8117FJM@public.gmane.org>:> > Hi, > > thanks for your device, but I also tried this. I restarted my whole > machine to be sure. But it does not work. I found out something new: > If I include this method from a module, it can be found. But all the > other methods are not found - also the association proxies! > > It seems to me, that rails just instantiates a raw ActiveRecord object > just with the name of my model. The list of methods you get with > ".methods()" only contains the default inherited methods. I am > absolutely confused.I presume that we are talking about the same server hardware running in production vs development mode here? Are you using the same server s/w? Webrick or whatever. I believe the differences between the two modes are purely the differences between production.rb and development.rb in config/environments (config.action_controller.perform_caching and so on). Have you modified one of these away from the default? If not then you could change the contents of production.rb to be the same as development.rb and then iteratively change it back till you find the trigger that makes it fail. This may give a clue. Colin
ms
2009-Sep-04 08:36 UTC
Re: Strange NoMethodErrors in production mode, I just don''t know what to do.
Hi, I am very thankful for you answer. Let me answer you points: Yes, it''s the same machine and I use the same server: webrick. You second point: Before my post, I copied the configurations from the test environment to development environment and then I''ve got no problems. As you mentioned, the config.action_controller.perform_caching ist the problem. If it is set to false, I face the problems described. But development with config.action_controller.perform_caching set to true does not reload the source code after a new request, so I have to restart the server every time I make changes to the source. Last night, I tried to get some more information about the problem: as I mentioned, the error appears, when I do the second request in the webbrowser. The first access is always successful. I put out the ".methods()" list of the model instance and there I could see, that my own methods are not listed. Also the access methods of the association proxies seem not to be existent anymore. Then I tried the following: I extracted my methods and put them into a module. I included this module and suddenly those methods I extracted were existent again, also after a few reloads. But still, the association proxy methods are missing. I can''t explain this to me. Do you have another idea? Thank you very much. ms
Colin Law
2009-Sep-04 08:43 UTC
Re: Strange NoMethodErrors in production mode, I just don''t know what to do.
2009/9/4 ms <ms-cGBD8117FJM@public.gmane.org>:> > Hi, > > I am very thankful for you answer. > > Let me answer you points: Yes, it''s the same machine and I use the > same server: webrick. You second point: Before my post, I copied the > configurations from the test environment to development environment > and then I''ve got no problems. As you mentioned, the > config.action_controller.perform_caching ist the problem. If it is set > to false, I face the problems described. But development with > config.action_controller.perform_caching set to true does not reload > the source code after a new request, so I have to restart the server > every time I make changes to the source.Sorry I am not quite getting that. You say ''As you mentioned, the config.action_controller.perform_caching ist the problem. If it is set to false, I face the problems described''. So you get the problem when caching is set to false? But that is the development mode. Colin> > Last night, I tried to get some more information about the problem: as > I mentioned, the error appears, when I do the second request in the > webbrowser. The first access is always successful. I put out the > ".methods()" list of the model instance and there I could see, that my > own methods are not listed. Also the access methods of the association > proxies seem not to be existent anymore. > > Then I tried the following: I extracted my methods and put them into a > module. I included this module and suddenly those methods I extracted > were existent again, also after a few reloads. But still, the > association proxy methods are missing. I can''t explain this to me. > > Do you have another idea? > > Thank you very much. > ms > > >
Frederick Cheung
2009-Sep-04 08:43 UTC
Re: Strange NoMethodErrors in production mode, I just don''t know what to do.
On Sep 4, 9:36 am, ms <m...-cGBD8117FJM@public.gmane.org> wrote:> Hi, > > I am very thankful for you answer. > > Let me answer you points: Yes, it''s the same machine and I use the > same server: webrick. You second point: Before my post, I copied the > configurations from the test environment to development environment > and then I''ve got no problems. As you mentioned, the > config.action_controller.perform_caching ist the problem. If it is set > to false, I face the problems described. But development with > config.action_controller.perform_caching set to true does not reload > the source code after a new request, so I have to restart the server > every time I make changes to the source. >If class caching (or rather the absence thereof) is causing the problem it is usually a sign that you are confusing the dependencies system. One way of doing this is to use require to require classes that are part of your application - you should need to do this at all since rails will load the classes for you (use require_dependency if you have to)> Then I tried the following: I extracted my methods and put them into a > module. I included this module and suddenly those methods I extracted > were existent again, also after a few reloads. But still, the > association proxy methods are missing. I can''t explain this to me.I wouldn''t spend time on looking for workaround like this - you will probably just confuse the issue. Fred> > Do you have another idea? > > Thank you very much. > ms
ms
2009-Sep-04 08:57 UTC
Re: Strange NoMethodErrors in production mode, I just don''t know what to do.
Hi, omg, that helped, thank you! :) In one model, I did two ''requires''. I changed them to ''require_dependency'' and that works for me now. The only question I asked myself is, why I have to do ''require'' there. I just commented these lines with: "Just a workaround. Somehow rails does not autoload these classes." I just removed the ''requires'' completely, but then some classes are not autoloaded. I need to do a ''require_dependeny''. How does this come since rails normally autoloads all classes? Thanks again, ms