0

I've using nginx + unicorn at production

And I've got following error at log/unicorn.log but it's work fine at localhost (in both environments development and production)

I, [2012-07-01T19:20:39.905978 #15422]  INFO -- : Refreshing Gem list
E, [2012-07-01T19:20:40.526582 #15418] ERROR -- : uninitialized constant ApplicationController::CanCan (NameError)

for line

rescue_from CanCan::AccessDenied do |exception|

I have gem 'cancan' in Gemfile (below gem 'rails'). Cancan gem is installed. I've tried both versions 1.6.7 and 1.6.8

current$ bundle exec gem list cancan

*** LOCAL GEMS ***

cancan (1.6.7)

current$ bundle exec rails -v
Rails 3.2.3

current$ ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]

current$ bundle exec rails c production
Loading production environment (Rails 3.2.3)
1.9.3p125 :001 > CanCan
 => CanCan 
1.9.3p125 :002 > 

What can be wrong with my configuration?

upd: require 'cancan' in application_controller cause error No such file to load -- cancan (LoadError)

My Gemfile

ck3g
  • 5,829
  • 3
  • 32
  • 52
  • please post your gemfile. how are you requiring your gems? it looks like it's not properly required. does a 'require "cancan"' in your application controller help? – phoet Jul 03 '12 at 18:09
  • There was link to my Gemfile but I duplicate it again. `require 'cancan'` doesn't helped my. How can I properly require it? The problem is what it's works at localhost – ck3g Jul 04 '12 at 06:20

1 Answers1

1

I think unicorn doesn't load new gems on restart.

/etc/init.d/unicorn_<project_name> stop
/etc/init.d/unicorn_<project_name> start

Fix the problem

ck3g
  • 5,829
  • 3
  • 32
  • 52
  • Thanks! I've been scratching my head over this since I started using Unicorn. Previously I had to reboot the server for it to work again. –  Oct 14 '12 at 15:03