decostop
2008-Sep-18 19:21 UTC
user_observer (restful_authentication) causes failure in loading rails
I have restful_authentication in use on an app and it has been working fine, but I recently was changing the account creation flow and needed to enable the UserObserver. I did so by including it in the environment.rb (config.active_record.observers = :user_observer) and Rails wouldn''t start. I got the following error; source/communitysites/vendor/rails/activerecord/lib/active_record/ base.rb:1672:in `method_missing_without_paginate'': undefined method `format_attribute'' for #<Class:0x2256a14> (NoMethodError) from /source/communitysites/vendor/plugins/will_paginate/lib/ will_paginate/finder.rb:164:in `method_missing'' from /source/communitysites/app/forums/models/post.rb:7 from /source/communitysites/vendor/rails/activesupport/lib/ active_support/dependencies.rb:216:in `load_without_new_constant_marking'' from /source/communitysites/vendor/rails/activesupport/lib/ active_support/dependencies.rb:216:in `load_file'' from /source/communitysites/vendor/rails/activesupport/lib/ active_support/dependencies.rb:355:in `new_constants_in'' from /source/communitysites/vendor/rails/activesupport/lib/ active_support/dependencies.rb:215:in `load_file'' from /source/communitysites/vendor/rails/activesupport/lib/ active_support/dependencies.rb:96:in `require_or_load'' from /source/communitysites/vendor/rails/activesupport/lib/ active_support/dependencies.rb:261:in `load_missing_constant'' ... 76 levels... from /source/communitysites/vendor/rails/activesupport/lib/ active_support/dependencies.rb:511:in `require'' from /source/communitysites/vendor/rails/railties/lib/commands/ server.rb:39 from script/server:3:in `require'' from script/server:3 I get the same error when all the contents of UserObserver are commented out, but don''t get it if I load a different arbitrarily named observer class. Adding some more debug statements to the Rails dependencies code provided me this information;> Booting Mongrel (use ''script/server webrick'' to force WEBrick)=> Rails 2.1.0 application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server ** Starting Mongrel listening at 0.0.0.0:3000 ** Starting Rails with development environment... Error while attempting to load ''''. Removing partially loaded constants ([])... Error while attempting to load ''''. Removing partially loaded constants ([])... Error while attempting to load ''''. Removing partially loaded constants ([])... Error while attempting to load ''''. Removing partially loaded constants ([])... DEPRECATION WARNING: config.action_view.cache_template_extensions option has been deprecated and has no affect. Please remove it from your config files. See http://www.rubyonrails.org/deprecation for details. (called from send at ./script/../config/../vendor/rails/ railties/lib/initializer.rb:464) Error while attempting to load ''''. Removing partially loaded constants ([])... Error while attempting to load ''''. Removing partially loaded constants (["Post"])... Error while attempting to load ''''. Removing partially loaded constants (["Post"])... Error while attempting to load ''''. Removing partially loaded constants (["Forum"])... Error while attempting to load ''''. Removing partially loaded constants (["Post"])... Error while attempting to load ''''. Removing partially loaded constants (["Post"])... Error while attempting to load ''''. Removing partially loaded constants (["Forum"])... Error while attempting to load ''''. Removing partially loaded constants (["User"])... Error while attempting to load ''''. Removing partially loaded constants (["RAILS_GEM_VERSION", "RedHillConsulting", "Technoweenie", "RAILS_DEFAULT_LOGGER", "NR_CONFIG_FILE", "RPM_AGENT_ENABLED", "RPM_DEVELOPER", "RPM_TRACERS_ENABLED", "RAILS_CACHE"])... Error while attempting to load ''''. Removing partially loaded constants ([])... Exiting Error while attempting to load ''''. Removing partially loaded constants (["OPTIONS"])... After which I get the error. I am not very familiar with the Rails internals since I am fairly new to the platform as well as the Ruby language. Any tips on approaches for troubleshooting this (apparent dependencies issue) would be greatly appreciated. Kevin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
decostop
2008-Sep-18 21:34 UTC
Re: user_observer (restful_authentication) causes failure in loading rails
It appears since the observer is setup and loads the observed class (User) and my User class has_many posts my post class from Beast gets loaded. Looking through the code I found the format_attribute class called in the Post class is defined in forums.rb file in my lib directory. In railties/lib/initializer.rb it seems load_observers is pretty much the last thing called in initialization. However, obviously lib must get processed later in order to produce the error I am getting. I now just need to figure out how to get lib processed earlier or instead of config.active_record.observers use UserObserver.instance somewhere where it will get called after lib gets processed. It appears that a UserObserver.instance call at the end of the forums.rb is a quick way to get around this, but far from clean/intuitive/well organized. Any recommendations on where the best place to handle this is? On Sep 18, 12:21 pm, decostop <blaisde...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have restful_authentication in use on an app and it has been working > fine, but I recently was changing the account creation flow and needed > to enable the UserObserver. I did so by including it in the > environment.rb (config.active_record.observers = :user_observer) and > Rails wouldn''t start. > > I got the following error; > source/communitysites/vendor/rails/activerecord/lib/active_record/ > base.rb:1672:in `method_missing_without_paginate'': undefined method > `format_attribute'' for #<Class:0x2256a14> (NoMethodError) > from /source/communitysites/vendor/plugins/will_paginate/lib/ > will_paginate/finder.rb:164:in `method_missing'' > from /source/communitysites/app/forums/models/post.rb:7 > from /source/communitysites/vendor/rails/activesupport/lib/ > active_support/dependencies.rb:216:in > `load_without_new_constant_marking'' > from /source/communitysites/vendor/rails/activesupport/lib/ > active_support/dependencies.rb:216:in `load_file'' > from /source/communitysites/vendor/rails/activesupport/lib/ > active_support/dependencies.rb:355:in `new_constants_in'' > from /source/communitysites/vendor/rails/activesupport/lib/ > active_support/dependencies.rb:215:in `load_file'' > from /source/communitysites/vendor/rails/activesupport/lib/ > active_support/dependencies.rb:96:in `require_or_load'' > from /source/communitysites/vendor/rails/activesupport/lib/ > active_support/dependencies.rb:261:in `load_missing_constant'' > ... 76 levels... > from /source/communitysites/vendor/rails/activesupport/lib/ > active_support/dependencies.rb:511:in `require'' > from /source/communitysites/vendor/rails/railties/lib/commands/ > server.rb:39 > from script/server:3:in `require'' > from script/server:3 > > I get the same error when all the contents of UserObserver are > commented out, but don''t get it if I load a different arbitrarily > named observer class. Adding some more debug statements to the Rails > dependencies code provided me this information;> Booting Mongrel (use ''script/server webrick'' to force WEBrick) > > => Rails 2.1.0 application starting onhttp://0.0.0.0:3000 > => Call with -d to detach > => Ctrl-C to shutdown server > ** Starting Mongrel listening at 0.0.0.0:3000 > ** Starting Rails with development environment... > Error while attempting to load ''''. Removing partially loaded constants > ([])... > Error while attempting to load ''''. Removing partially loaded constants > ([])... > Error while attempting to load ''''. Removing partially loaded constants > ([])... > Error while attempting to load ''''. Removing partially loaded constants > ([])... > DEPRECATION WARNING: config.action_view.cache_template_extensions > option has been deprecated and has no affect. Please remove it from > your config files. Seehttp://www.rubyonrails.org/deprecationfor > details. (called from send at ./script/../config/../vendor/rails/ > railties/lib/initializer.rb:464) > Error while attempting to load ''''. Removing partially loaded constants > ([])... > Error while attempting to load ''''. Removing partially loaded constants > (["Post"])... > Error while attempting to load ''''. Removing partially loaded constants > (["Post"])... > Error while attempting to load ''''. Removing partially loaded constants > (["Forum"])... > Error while attempting to load ''''. Removing partially loaded constants > (["Post"])... > Error while attempting to load ''''. Removing partially loaded constants > (["Post"])... > Error while attempting to load ''''. Removing partially loaded constants > (["Forum"])... > Error while attempting to load ''''. Removing partially loaded constants > (["User"])... > Error while attempting to load ''''. Removing partially loaded constants > (["RAILS_GEM_VERSION", "RedHillConsulting", "Technoweenie", > "RAILS_DEFAULT_LOGGER", "NR_CONFIG_FILE", "RPM_AGENT_ENABLED", > "RPM_DEVELOPER", "RPM_TRACERS_ENABLED", "RAILS_CACHE"])... > Error while attempting to load ''''. Removing partially loaded constants > ([])... > Exiting > Error while attempting to load ''''. Removing partially loaded constants > (["OPTIONS"])... > > After which I get the error. I am not very familiar with the Rails > internals since I am fairly new to the platform as well as the Ruby > language. Any tips on approaches for troubleshooting this (apparent > dependencies issue) would be greatly appreciated. > > Kevin--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---