# User\_observer (restful\_authentication) causes failure in loading rails

**URL:** <https://www.ruby-forum.com/t/user-observer-restful-authentication-causes-failure-in-loading-rails/148987>\
**Category:** Rails\
**Created:** [September 18, 2008, 11:22pm UTC](https://www.ruby-forum.com/t/user-observer-restful-authentication-causes-failure-in-loading-rails/148987 "2008-09-18T23:22:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![decostop](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4da419/32.png) [@decostop](https://www.ruby-forum.com/u/decostop)\
**Post date:** [September 18, 2008, 11:22pm UTC](https://www.ruby-forum.com/t/user-observer-restful-authentication-causes-failure-in-loading-rails/148987/1 "2008-09-18T23:22:29Z")

</div>

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](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 [Ruby on Rails — A web-app framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.](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

---

<div class="post-metadata">

**Author:** ![decostop](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4da419/32.png) [@decostop](https://www.ruby-forum.com/u/decostop)\
**Post date:** [September 18, 2008, 11:35pm UTC](https://www.ruby-forum.com/t/user-observer-restful-authentication-causes-failure-in-loading-rails/148987/2 "2008-09-18T23:35:58Z")

</div>

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?
