A strange ERROR in production mode: undefined method `controller_name' for nil:NilClass

187 views
Skip to first unread message

Valeri

unread,
Sep 19, 2008, 7:43:41 AM9/19/08
to CommunityEngine
Hi.
Rails 2.1.0

I has received A strange ERROR in production mode when try save post.

Processing PostsController#create

NoMethodError (undefined method `controller_name' for nil:NilClass):

This bug only in production mode.

The error log same as at: http://pastie.org/259783.txt

Valeri

unread,
Sep 19, 2008, 8:17:22 AM9/19/08
to CommunityEngine
This ERROR occured when

onfig.action_controller.perform_caching = true

No any errors if perform_caching=false

Bruno Bornsztein

unread,
Sep 19, 2008, 2:55:12 PM9/19/08
to communi...@googlegroups.com
The error log show that it's processing CommentsController#create. Which one is it (or both)?

Valeri

unread,
Sep 20, 2008, 1:50:14 AM9/20/08
to CommunityEngine
Hi Bruno!

The error occured in all actions which used *_sweeper.rb
No any errors if setup Config.action_controller.perform_caching=false

This problem may be resolved by Ruby core hack...
ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/caching/
sweeping.rb
def after(controller)
callback(:after) if controller.perform_caching
self.controller = nil
end

See at "self.controller = nil" .

The function "after" called twice when Post( or Comments)
saved(create, update).
But after first call controller instance removed from memory by
"self.controller = nil",
so second call raise error - "...undefined method 'ontroller_name'..."



But Ruby core hack is not very good idea.




Valeri

unread,
Sep 20, 2008, 4:08:10 AM9/20/08
to CommunityEngine
Bruno, Hi Again!

I found the real problem!

The any controllers from vendor/plugins/community_engine/app/
controllers/*
not fully overrides by my own controller(s) from app/controllers/*.

So if I have my own controller ex. app/controllers/
posts_controller.rb, the CE loading both:
app/controllers/posts_controller.rb
and
vendor/plugins/community_engine/app/controllers/posts_controller.rb

So when perform_caching=true raised error when try update(create)
Post, because function "def after(controller)" from
ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/caching/
sweeping.rb does not accept double call.



The ERROR resolved easy:
If You have Your own controller /app/controllers/posts_controller.rb,
You need just remove(rename) the corresponding controller:
vendor/plugins/community_engine/app/controllers/posts_controller.rb

This manipulation prevent double call function "def after(controller)"


Reply all
Reply to author
Forward
0 new messages