Savage Beast: Custom user model methods get lost

0 views
Skip to first unread message

Adrian

unread,
Mar 5, 2008, 7:40:36 PM3/5/08
to Ruby on Rails: Talk
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,"<strong>#{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

Jodi Showers

unread,
Mar 5, 2008, 8:24:41 PM3/5/08
to rubyonra...@googlegroups.com
Adrian -

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

>
> 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.


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

Adrian

unread,
Mar 6, 2008, 1:29:56 PM3/6/08
to Ruby on Rails: Talk
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

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

Regards,
Adrian

On Mar 6, 2:24 am, Jodi Showers <j...@nnovation.ca> wrote:
> Adrian -
Reply all
Reply to author
Forward
0 new messages