# Savage Beast: Custom user model methods get lost

**URL:** <https://www.ruby-forum.com/t/savage-beast-custom-user-model-methods-get-lost/131104>\
**Category:** Rails\
**Created:** [March 6, 2008, 1:41am UTC](https://www.ruby-forum.com/t/savage-beast-custom-user-model-methods-get-lost/131104 "2008-03-06T01:41:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adrian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@adrian](https://www.ruby-forum.com/u/adrian)\
**Post date:** [March 6, 2008, 1:41am UTC](https://www.ruby-forum.com/t/savage-beast-custom-user-model-methods-get-lost/131104/1 "2008-03-06T01:41:51Z")

</div>

I’m currently trying to install savage beast and it has worked well to  
the point that I’m able to post an read topics.

However, I’ve run into the following weirdness that I haven’t been  
able to figure out:

At the Forums’ index view I get the following error (trace at the  
bottom of my post):  
“Showing vendor/plugins/savage\_beast/app/views/forums/index.html.erb  
where line #53 raised:  
undefined method `display\_name’ for #User:0x867efa0”

What makes it totally weird is that face that I don’t get this error  
the first time I call this page after a fresh server start. The page  
loads fine first (displaying the correct display\_name) but then starts  
to fail with this error on every call.

The line that fails is the following one:  
“\<%= ‘by  
{user}’[:by\_user,”**#{h(forum.recent\_post.user.display\_name)}\</  
strong\>"] %\>"**

I can change it to “forum.recent\_post.user.login” or any other  
database field and that works. The model correctly loads the database  
fields and creates the methods to access them all. All methods i  
defined in my app/model/user.rb are gone however.

I tried “forum.recent\_post.user.instance\_of? User” and that oddly  
returns “false” (“true” right after a server reboot).

I tried this on Mongrel, WeBrick and Apache and the error is  
consistent on all servers. I’m running Rails 2.0.2 and ruby 1.8.6.

Any suggestions on what could be wrong?

Here’s the complete trace of the error:  
vendor/rails/activerecord/lib/active\_record/attribute\_methods.rb:  
205:in `method_missing' vendor/rails/activerecord/lib/active_record/associations/ association_proxy.rb:125:in`send’  
vendor/rails/activerecord/lib/active\_record/associations/  
association\_proxy.rb:125:in `method_missing' vendor/plugins/savage_beast/app/views/forums/index.html.erb:53:in`\_run\_erb\_47vendor47plugins47savage\_beast47app47views47forums47index46html46erb’  
vendor/plugins/savage\_beast/app/views/forums/index.html.erb:27:in  
`each' vendor/plugins/savage_beast/app/views/forums/index.html.erb:27:in`\_run\_erb\_47vendor47plugins47savage\_beast47app47views47forums47index46html46erb’  
vendor/rails/actionpack/lib/action\_view/base.rb:637:in `send' vendor/rails/actionpack/lib/action_view/base.rb:637:in`compile\_and\_render\_template’  
vendor/rails/actionpack/lib/action\_view/base.rb:365:in  
`render_template' vendor/rails/actionpack/lib/action_view/base.rb:316:in`render\_file’  
vendor/rails/actionpack/lib/action\_controller/base.rb:1100:in  
`render_for_file' vendor/rails/actionpack/lib/action_controller/base.rb:858:in`render\_with\_no\_layout’  
vendor/rails/actionpack/lib/action\_controller/base.rb:872:in  
`render_with_no_layout' vendor/rails/actionpack/lib/action_controller/layout.rb:262:in`render\_without\_benchmark’  
vendor/rails/actionpack/lib/action\_controller/benchmarking.rb:51:in  
`render' C:/ruby/lib/ruby/1.8/benchmark.rb:293:in`measure’  
vendor/rails/actionpack/lib/action\_controller/benchmarking.rb:51:in  
`render' vendor/rails/actionpack/lib/action_controller/mime_responds.rb:131:in`send’  
vendor/rails/actionpack/lib/action\_controller/mime\_responds.rb:131:in  
`custom' vendor/rails/actionpack/lib/action_controller/mime_responds.rb:156:in`call’  
vendor/rails/actionpack/lib/action\_controller/mime\_responds.rb:156:in  
`respond' vendor/rails/actionpack/lib/action_controller/mime_responds.rb:150:in`each’  
vendor/rails/actionpack/lib/action\_controller/mime\_responds.rb:150:in  
`respond' vendor/rails/actionpack/lib/action_controller/mime_responds.rb:107:in`respond\_to’  
vendor/plugins/savage\_beast/app/controllers/forums\_controller.rb:12:in  
`index' vendor/rails/actionpack/lib/action_controller/base.rb:1158:in`send’  
vendor/rails/actionpack/lib/action\_controller/base.rb:1158:in  
`perform_action_without_filters' vendor/rails/actionpack/lib/action_controller/filters.rb:697:in`call\_filters’  
vendor/rails/actionpack/lib/action\_controller/filters.rb:689:in  
`perform_action_without_benchmark' vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in`perform\_action\_without\_rescue’  
C:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in`perform\_action\_without\_rescue’  
vendor/rails/actionpack/lib/action\_controller/rescue.rb:199:in  
`perform_action_without_caching' vendor/rails/actionpack/lib/action_controller/caching.rb:678:in`perform\_action’  
vendor/rails/activerecord/lib/active\_record/connection\_adapters/  
abstract/query\_cache.rb:33:in `cache' vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in`cache’  
vendor/rails/actionpack/lib/action\_controller/caching.rb:677:in  
`perform_action' vendor/rails/actionpack/lib/action_controller/base.rb:524:in`send’  
vendor/rails/actionpack/lib/action\_controller/base.rb:524:in  
`process_without_filters' vendor/rails/actionpack/lib/action_controller/filters.rb:685:in`process\_without\_session\_management\_support’  
vendor/rails/actionpack/lib/action\_controller/session\_management.rb:  
123:in `process' vendor/rails/actionpack/lib/action_controller/base.rb:388:in`process’  
vendor/rails/actionpack/lib/action\_controller/dispatcher.rb:171:in  
`handle_request' vendor/rails/actionpack/lib/action_controller/dispatcher.rb:115:in`dispatch’  
vendor/rails/actionpack/lib/action\_controller/dispatcher.rb:126:in  
`dispatch_cgi' vendor/rails/actionpack/lib/action_controller/dispatcher.rb:9:in`dispatch’  
vendor/rails/railties/lib/fcgi\_handler.rb:101:in `process_request' vendor/rails/railties/lib/fcgi_handler.rb:149:in`with\_signal\_handler’  
vendor/rails/railties/lib/fcgi\_handler.rb:99:in `process_request' vendor/rails/railties/lib/fcgi_handler.rb:77:in`process\_each\_request’  
C:/ruby/lib/ruby/site\_ruby/1.8/fcgi.rb:612:in `each_cgi' C:/ruby/lib/ruby/site_ruby/1.8/fcgi.rb:609:in`each’  
C:/ruby/lib/ruby/site\_ruby/1.8/fcgi.rb:609:in `each_cgi' vendor/rails/railties/lib/fcgi_handler.rb:76:in`process\_each\_request’  
vendor/rails/railties/lib/fcgi\_handler.rb:50:in `process!' vendor/rails/railties/lib/fcgi_handler.rb:24:in`process!’  
public/dispatch.fcgi:24

---

<div class="post-metadata">

**Author:** ![adrian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@adrian](https://www.ruby-forum.com/u/adrian)\
**Post date:** [March 6, 2008, 2:25am UTC](https://www.ruby-forum.com/t/savage-beast-custom-user-model-methods-get-lost/131104/2 "2008-03-06T02:25:13Z")

</div>

Adrian -

On 5-Mar-08, at 7:40 PM, Adrian wrote:

> where line #53 raised:  
> undefined method `display\_name’ for #User:0x867efa0"
> 
> What makes it totally weird is that face that I don’t get this error  
> the first time I call this page after a fresh server start. The page  
> loads fine first (displaying the correct display\_name) but then starts  
> to fail with this error on every call.

this ‘feels’ like a model reloading issue.

I haven’t ported savage beast to rails 2.02 or the latest engines  
plugin - there’s likely something going on.

I would head over the the engine’s list and ask James about the  
behavior you’re seeing. If you do come to a solution, I can roll the  
change in.

cheers,  
Jodi

---

<div class="post-metadata">

**Author:** ![adrian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@adrian](https://www.ruby-forum.com/u/adrian)\
**Post date:** [March 6, 2008, 7:30pm UTC](https://www.ruby-forum.com/t/savage-beast-custom-user-model-methods-get-lost/131104/3 "2008-03-06T19:30:56Z")

</div>

Thanks a lot, that got me on the right track!

I’m still not sure what’s going on and I currently don’t have the time  
to look into it further. It seems to be related to a known engines  
problem where models don’t get reloaded.

## It only affects development mode and I was able to fix it by adding following lines to savage beast’s init.rb:

# FIX for engines model reloading issue in development mode

## if ENV[‘RAILS\_ENV’] != ‘production’ load\_paths.each do |path| Dependencies.load\_once\_paths.delete(path) end end

I’ve found the fix on the engines mailing list here:  
[http://lists.rails-engines.org/pipermail/engine-users-rails-engines.org/2008-January/000629.html](http://lists.rails-engines.org/pipermail/engine-users-rails-engines.org/2008-January/000629.html)

And this seems to be realted to it:  
[http://dev.rubyonrails.org/ticket/10488](http://dev.rubyonrails.org/ticket/10488)

Regards,  
Adrian
