In Production, the Strange Error 'undefined method `controller_name' for nil:NilClass' is Back

32 views
Skip to first unread message

SS

unread,
Nov 18, 2009, 12:41:38 PM11/18/09
to CommunityEngine
Hello,
I spent the last whole week trying to fix the below error in
Production. In Development it all works fine, however when I try to
edit profile information for a user in production, I keep getting the
error message below. The interesting thing is that after I get this
error message and visit my user profile, all the changes have been
successfully committed in the database. I've overridden only the index
() method in my own users_controller.rb in the following manner:

require "RMagick"
class UsersController < BaseController

def index
# Some logic goes here.
end
end


I read and tried the suggested solution here:

http://groups.google.com/group/communityengine/browse_thread/thread/b84154e5228bf9f3?pli=1

This however didn't work for me, plus if it worked I would try to find
a different solution since I don't want to remove and duplicate the
original file for any method that I override in i.e.
users_controller.rb.


The Error message that I get after the database query is processed:

Processing UsersController#update (for 70.75.54.26 at 2009-11-18
09:21:45) [PUT]
Parameters: {"user"=>{"birthday(2i)"=>"11", "birthday(3i)"=>"4",
"zip"=>"", "description"=>"<p>Test Description</p>", "birthday
(1i)"=>"1994"}, "commit"=>"Save Changes",
"authenticity_token"=>"4QLH9ovpWwefeZOavRXaz4BXt1Y/aTOfW3N7SvA=",
"country_id"=>"1", "id"=>"administrator", "metro_area_id"=>"4",
"tag_list"=>"", "state_id"=>"3"}
Redirected to http://mypage.com/administrator


NoMethodError (undefined method `controller_name' for nil:NilClass):
haml (2.2.3) lib/sass/plugin/rails.rb:19:in `process'
/home/heroku_rack/lib/static_assets.rb:9:in `call'
/home/heroku_rack/lib/last_access.rb:25:in `call'
/home/heroku_rack/lib/date_header.rb:14:in `call'
thin (1.0.1) lib/thin/connection.rb:80:in `pre_process'
thin (1.0.1) lib/thin/connection.rb:78:in `catch'
thin (1.0.1) lib/thin/connection.rb:78:in `pre_process'
thin (1.0.1) lib/thin/connection.rb:57:in `process'
thin (1.0.1) lib/thin/connection.rb:42:in `receive_data'
eventmachine (0.12.6) lib/eventmachine.rb:240:in `run_machine'
eventmachine (0.12.6) lib/eventmachine.rb:240:in `run'
thin (1.0.1) lib/thin/backends/base.rb:57:in `start'
thin (1.0.1) lib/thin/server.rb:150:in `start'
thin (1.0.1) lib/thin/controllers/controller.rb:80:in `start'
thin (1.0.1) lib/thin/runner.rb:173:in `send'
thin (1.0.1) lib/thin/runner.rb:173:in `run_command'
thin (1.0.1) lib/thin/runner.rb:139:in `run!'
thin (1.0.1) bin/thin:6
/usr/local/bin/thin:20:in `load'
/usr/local/bin/thin:20


Please help with any ideas that you may have for me to try. It's kind
of a showstopper for me because users can't edit any profile
information. I'm running on Heroku.

Cheers,
Siyan

Levi Rosol

unread,
Nov 18, 2009, 3:29:00 PM11/18/09
to communi...@googlegroups.com
This looks similar to the issue I have been having.

--
Levi Rosol
Twitter: @LeviRosol




--

You received this message because you are subscribed to the Google Groups "CommunityEngine" group.
To post to this group, send email to communi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/communityengine?hl=.



mike muldoon

unread,
Nov 18, 2009, 7:14:40 PM11/18/09
to communi...@googlegroups.com
I have started seeing this, too, (I am on edge). I can not repro in my
dev environment, but I can repro it in production.

UsersController.update exits normally, but the redirection fails with
this stacktrace:

NoMethodError (You have a nil object when you didn't expect it!
The error occurred while evaluating nil.controller_name):
haml (2.0.9) lib/sass/plugin/rails.rb:19:in `process'
passenger (2.2.4)
lib/phusion_passenger/rack/request_handler.rb:91:in `process_request'
passenger (2.2.4)
lib/phusion_passenger/abstract_request_handler.rb:206:in `main_loop'
passenger (2.2.4)
lib/phusion_passenger/railz/application_spawner.rb:376:in
`start_request_handler'
passenger (2.2.4)
lib/phusion_passenger/railz/application_spawner.rb:334:in
`handle_spawn_application'
passenger (2.2.4) lib/phusion_passenger/utils.rb:182:in `safe_fork'
passenger (2.2.4)
lib/phusion_passenger/railz/application_spawner.rb:332:in
`handle_spawn_application'
passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:351:in `__send__'
passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:351:in `main_loop'
passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:195:in
`start_synchronously'
passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:162:in `start'
passenger (2.2.4)
lib/phusion_passenger/railz/application_spawner.rb:213:in `start'
passenger (2.2.4) lib/phusion_passenger/spawn_manager.rb:261:in
`spawn_rails_application'
passenger (2.2.4)
lib/phusion_passenger/abstract_server_collection.rb:126:in
`lookup_or_add'
passenger (2.2.4) lib/phusion_passenger/spawn_manager.rb:255:in
`spawn_rails_application'
passenger (2.2.4)
lib/phusion_passenger/abstract_server_collection.rb:80:in
`synchronize'
passenger (2.2.4)
lib/phusion_passenger/abstract_server_collection.rb:79:in
`synchronize'
passenger (2.2.4) lib/phusion_passenger/spawn_manager.rb:254:in
`spawn_rails_application'
passenger (2.2.4) lib/phusion_passenger/spawn_manager.rb:153:in
`spawn_application'
passenger (2.2.4) lib/phusion_passenger/spawn_manager.rb:286:in
`handle_spawn_application'
passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:351:in `__send__'
passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:351:in `main_loop'
passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:195:in
`start_synchronously'


Version info:

Rails 2.3.2
ruby 1.8.6 (2008-08-11 patchlevel 287) [x86_64-linux] Ruby Enterprise
Edition 20090610

actionmailer (2.3.2)
actionpack (2.3.2)
activerecord (2.3.2)
activeresource (2.3.2)
activesupport (2.3.2)
authlogic (2.1.3)
aws-s3 (0.6.2)
builder (2.1.2)
calendar_date_select (1.15)
capistrano (2.5.5, 1.4.2)
desert (0.5.0)
extlib (0.9.12)
fastthread (1.0.7)
haml (2.0.9)
highline (1.5.1)
hpricot (0.8.1)
htmlentities (4.0.0)
icalendar (1.1.0)
json (1.1.7)
mime-types (1.16)
mysql (2.7)
needle (1.3.0)
net-scp (1.0.2)
net-sftp (2.0.2, 1.1.1)
net-ssh (2.0.11, 1.1.4)
net-ssh-gateway (1.0.1)
ohai (0.3.2)
passenger (2.2.4)
postgres (0.7.9.2008.01.28)
rack (1.0.0)
rails (2.3.2)
rake (0.8.7)
rmagick (2.9.2)
sqlite3-ruby (1.2.4)
systemu (1.2.0)
termios (0.9.4)
xml-simple (1.0.12)
> http://groups.google.com/group/communityengine?hl=en.
>

Bruno Bornsztein

unread,
Nov 18, 2009, 8:39:40 PM11/18/09
to communi...@googlegroups.com
Hi guys,
I'd love to help fix this, but I can't reproduce it locally. Here are
the steps I'm taking:
using rails 2.3.4

$ rails ce_test -m http://www.communityengine.org/edge_install_template.rb

In app/controllers, add:

class UsersController < BaseController

def index
#dummy
end

end

Then I start my app with: thin start -e production

No nil.controller_name error

Can you guys post a process I can reproduce to get this error?

mike muldoon

unread,
Nov 18, 2009, 9:01:39 PM11/18/09
to communi...@googlegroups.com
My staging/prod environments use passenger. I'm working with my
hosting provider to restart with mongrel, and see if that has any
effect.

I'll try a fresh CE install, too.

Bruno Bornsztein

unread,
Nov 18, 2009, 9:02:39 PM11/18/09
to communi...@googlegroups.com
I doubt passenger is the culprit (I have several sites running on
Passenger with no problems).

mike muldoon

unread,
Nov 18, 2009, 9:23:21 PM11/18/09
to communi...@googlegroups.com
Starting the app locally in production mode, I can now repro it. That
eliminates passenger.

In config/environments/production.rb, setting this to false fixes the bug:
config.action_controller.perform_caching = false

Not really a fix, but at least a clue.


On Wed, Nov 18, 2009 at 6:02 PM, Bruno Bornsztein

Bruno Bornsztein

unread,
Nov 18, 2009, 9:38:54 PM11/18/09
to communi...@googlegroups.com
CE version (with git commit sha)?
Rails version?
Any controllers or models overridden?
Can you repro this with a blank app?

Thanks, we'll get this tracked down.

mike muldoon

unread,
Nov 18, 2009, 9:43:38 PM11/18/09
to communi...@googlegroups.com
> CE version (with git commit sha)?
098e72abd7e731a9aa3102489f72d93e252f3d12
vendor/plugins/community_engine (v0.10.6-683-g098e72a)

> Rails version?
> Any controllers or models overridden?
application_controller.rb
sessions_controller.rb
topics_controller.rb
base_controller.rb
properties_controller.rb
tags_controller.rb
users_controller.rb

No models.

> Can you repro this with a blank app?
Testing that now...

mike muldoon

unread,
Nov 18, 2009, 9:52:51 PM11/18/09
to communi...@googlegroups.com
...and I can't repro with a clean CE edge install, in either dev or prod mode.

I will start purging my overridden controllers, see where that leads.

moritz

unread,
Nov 19, 2009, 11:50:17 AM11/19/09
to CommunityEngine
Knowing that I might repeat myself, I've reproducibly seen this error
in the past when:

(1) a controller is (partially) overridden
(2) there is a cache_sweeper line in the controller
(3) config.action_controller.perform_caching = true

Currently, my work-around is to comment the cache_sweeper out (in the
overriding controller), but I'm interested in a real solution.

Valeri's assessment in the following thread got me on the right track
to eliminate the issue: http://groups.google.com/group/communityengine/browse_thread/thread/b84154e5228bf9f3?pli=1

Please also note, that my last CE upgrade is a while back. Let me
know if I can help any further.

On Nov 18, 6:38 pm, Bruno Bornsztein <bruno.bornszt...@gmail.com>
wrote:
> CE version (with git commit sha)?
> Rails version?
> Any controllers or models overridden?
> Can you repro this with a blank app?
>
> Thanks, we'll get this tracked down.
>
> On Wed, Nov 18, 2009 at 8:23 PM, mike muldoon <mike.muld...@gmail.com> wrote:
> > Starting the app locally in production mode, I can now repro it. That
> > eliminates passenger.
>
> > In config/environments/production.rb, setting this to false fixes the bug:
> > config.action_controller.perform_caching             = false
>
> > Not really a fix, but at least a clue.
>
> > On Wed, Nov 18, 2009 at 6:02 PM, Bruno Bornsztein
> > <bruno.bornszt...@gmail.com> wrote:
> >> I doubt passenger is the culprit (I have several sites running on
> >> Passenger with no problems).
>
> >> On Wed, Nov 18, 2009 at 8:01 PM, mike muldoon <mike.muld...@gmail.com> wrote:
> >>> My staging/prod environments use passenger. I'm working with my
> >>> hosting provider to restart with mongrel, and see if that has any
> >>> effect.
>
> >>> I'll try a fresh CE install, too.
>
> >>> On Wed, Nov 18, 2009 at 5:39 PM, Bruno Bornsztein
> >>> <bruno.bornszt...@gmail.com> wrote:
> >>>> Hi guys,
> >>>> I'd love to help fix this, but I can't reproduce it locally. Here are
> >>>> the steps I'm taking:
> >>>> using rails 2.3.4
>
> >>>> $ rails ce_test -m http://www.communityengine.org/edge_install_template.rb
>
> >>>> In app/controllers, add:
>
> >>>> class UsersController < BaseController
>
> >>>>  def index
> >>>>    #dummy
> >>>>  end
>
> >>>> end
>
> >>>> Then I start my app with: thin start -e production
>
> >>>> No nil.controller_name error
>
> >>>> Can you guys post a process I can reproduce to get this error?
>
> >>>>> On Wed, Nov 18, 2009 at 12:29 PM, Levi Rosol <levi.ro...@gmail.com> wrote:
> >>>>> > This looks similar to the issue I have been having.
>
> >>>>> > --
> >>>>> > Levi Rosol
> >>>>> > Twitter: @LeviRosol
>
> >>>>> > On Wed, Nov 18, 2009 at 11:41 AM, SS <stoyan.stoitch...@gmail.com> wrote:
>
> >>>>> >> Hello,
> >>>>> >> I spent the last whole week trying to fix the below error in
> >>>>> >> Production. In Development it all works fine, however when I try to
> >>>>> >> edit profile information for a user in production, I keep getting the
> >>>>> >> error message below. The interesting thing is that after I get this
> >>>>> >> error message and visit my user profile, all the changes have been
> >>>>> >> successfully committed in the database. I've overridden only the index
> >>>>> >> () method in my own users_controller.rb in the following manner:
>
> >>>>> >> require "RMagick"
> >>>>> >> class UsersController < BaseController
>
> >>>>> >>  def index
> >>>>> >>    # Some logic goes here.
> >>>>> >>  end
> >>>>> >> end
>
> >>>>> >>  I read and tried the suggested solution here:
>
> >>>>> >>http://groups.google.com/group/communityengine/browse_thread/thread/b...
>
> >>>>> >> This however didn't work for me, plus if it worked I would try to find
> >>>>> >> a different solution since I don't want to remove and duplicate the
> >>>>> >> original file for any method that I override in i.e.
> >>>>> >> users_controller.rb.
>
> >>>>> >> The Error message that I get after the database query is processed:
>
> >>>>> >> Processing UsersController#update (for 70.75.54.26 at 2009-11-18
> >>>>> >> 09:21:45) [PUT]
> >>>>> >>  Parameters: {"user"=>{"birthday(2i)"=>"11", "birthday(3i)"=>"4",
> >>>>> >> "zip"=>"", "description"=>"<p>Test Description</p>", "birthday
> >>>>> >> (1i)"=>"1994"}, "commit"=>"Save Changes",
> >>>>> >> "authenticity_token"=>"4QLH9ovpWwefeZOavRXaz4BXt1Y/aTOfW3N7SvA=",
> >>>>> >> "country_id"=>"1", "id"=>"administrator", "metro_area_id"=>"4",
> >>>>> >> "tag_list"=>"", "state_id"=>"3"}
> >>>>> >> Redirected tohttp://mypage.com/administrator
> ...
>
> read more »

mike muldoon

unread,
Nov 19, 2009, 1:44:18 PM11/19/09
to communi...@googlegroups.com
How to repro with a base CE edge install: create
<base>/app/controllers/users_controller.rb, containing:

class UsersController < BaseController
cache_sweeper :taggable_sweeper, :only => [:activate, :update, :destroy]
end

Run in production mode, update your profile, hit save.

mike muldoon

unread,
Nov 19, 2009, 3:52:19 PM11/19/09
to communi...@googlegroups.com
Removing the cache_sweeper line from my overridden controller is a fix.

..which might make sense, if the cache_sweeper is trying to expire the
same thing twice.

SS

unread,
Nov 20, 2009, 7:06:56 PM11/20/09
to CommunityEngine
I don't understand why you would have the cache_sweeper in your
overridden controller anyway?
I'm getting the NoMethodError (undefined method `controller_name' for
nil:NilClass):
error message without having the cache_sweeper in my overridden class.

I still can't figure out why my app fails on save :(
any progress guys?

Siyan



On Nov 19, 1:52 pm, mike muldoon <mike.muld...@gmail.com> wrote:
> Removing the cache_sweeper line from my overridden controller is a fix.
>
> ..which might make sense, if the cache_sweeper is trying to expire the
> same thing twice.
>
> On Thu, Nov 19, 2009 at 10:44 AM, mike muldoon <mike.muld...@gmail.com> wrote:
> > How to repro with a base CE edge install: create
> > <base>/app/controllers/users_controller.rb, containing:
>
> > class UsersController < BaseController
> >  cache_sweeper :taggable_sweeper, :only => [:activate, :update, :destroy]
> > end
>
> > Run in production mode, update your profile, hit save.
>
> > On Thu, Nov 19, 2009 at 8:50 AM, moritz <a5s...@yahoo.com> wrote:
> >> Knowing that I might repeat myself, I've reproducibly seen this error
> >> in the past when:
>
> >> (1) a controller is (partially) overridden
> >> (2) there is a cache_sweeper line in the controller
> >> (3) config.action_controller.perform_caching = true
>
> >> Currently, my work-around is to comment the cache_sweeper out (in the
> >> overriding controller), but I'm interested in a real solution.
>
> >> Valeri's assessment in the following thread got me on the right track
> >> to eliminate the issue:http://groups.google.com/group/communityengine/browse_thread/thread/b...
> ...
>
> read more »

mike muldoon

unread,
Nov 20, 2009, 7:31:09 PM11/20/09
to communi...@googlegroups.com
Can you repro with a clean edge install? Like so: create
<base>/app/controllers/users_controller.rb, containing:

class UsersController < BaseController
cache_sweeper :taggable_sweeper, :only => [:activate, :update, :destroy]
end

Run in production mode, update your profile, hit save.

> --
>
> You received this message because you are subscribed to the Google Groups "CommunityEngine" group.
> To post to this group, send email to communi...@googlegroups.com.
> To unsubscribe from this group, send email to communityengi...@googlegroups.com.

SS

unread,
Nov 22, 2009, 3:33:12 PM11/22/09
to CommunityEngine
Sorry, Mike what do you mean by 'clean edge install'?

Fresh check out from repository?


On Nov 20, 5:31 pm, mike muldoon <mike.muld...@gmail.com> wrote:
> Can you repro with a clean edge install?  Like so: create
> <base>/app/controllers/users_controller.rb, containing:
>
> class UsersController < BaseController
>  cache_sweeper :taggable_sweeper, :only => [:activate, :update, :destroy]
> end
>
> Run in production mode, update your profile, hit save.
>
> ...
>
> read more »

mike muldoon

unread,
Nov 22, 2009, 3:43:55 PM11/22/09
to communi...@googlegroups.com

SS

unread,
Nov 25, 2009, 7:00:26 PM11/25/09
to CommunityEngine
I tried it, didn't work :(
same problem, same error....



On Nov 22, 1:43 pm, mike muldoon <mike.muld...@gmail.com> wrote:
> Yes:
> rails ce_test -mhttp://www.communityengine.org/edge_install_template.rb
> ...
>
> read more »
Reply all
Reply to author
Forward
0 new messages