uninitialized constant ApplicationController::CanCan (NameError) - ruby-on-rails

My application runs normally on development environment but I am getting the following error when I try to run > rails server -e production
I have searched for this and I found answers about restarting unicorn but I don't have unicorn in my application, what can I do to fix it ?
/app/controllers/application_controller.rb:6:in `<class:ApplicationController>': uninitialized constant ApplicationController::CanCan (NameError)
from /home/dexter/Desktop item/Triton/app/controllers/application_controller.rb:1:in `<top (required)>'
from /var/lib/gems/1.9.1/gems/ckeditor-4.0.4/app/controllers/ckeditor/application_controller.rb:1:in `<top (required)>'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:438:in `each'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:438:in `block in eager_load!'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:436:in `each'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:436:in `eager_load!'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/application/railties.rb:8:in `each'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/application/railties.rb:8:in `all'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:434:in `eager_load!'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `instance_exec'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `run'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:55:in `block in run_initializers'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `each'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `run_initializers'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/application.rb:136:in `initialize!'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/dexter/Desktop item/Triton/config/environment.rb:5:in `<top (required)>'
from /home/dexter/Desktop item/Triton/config.ru:3:in `block in <main>'
from /var/lib/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /var/lib/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from /home/dexter/Desktop item/Triton/config.ru:in `new'
from /home/dexter/Desktop item/Triton/config.ru:in `<main>'
from /var/lib/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
from /var/lib/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
from /var/lib/gems/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands/server.rb:46:in `app'
from /var/lib/gems/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
from /var/lib/gems/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands/server.rb:70:in `start'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:55:in `block in <top (required)>'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:50:in `tap'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
My application controller:
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :authenticate_user!
rescue_from CanCan::AccessDenied do |exception|
flash[:error] = exception.message
redirect_to root_path
end
private
def stored_location_for(resource_or_scope)
nil
end
def after_sign_in_path_for(resource_or_scope)
'/dashboard'
end
end
Gemfile > just posted the place of CanCan
group :assets do
gem 'cancan'
end

Remove cancan from your assets group in your Gemfile. The assets group are gems that are not to be used in production. Therefore when you run the application in production mode, gems in the assets block will be excluded.

Related

Uninitialized constant ActionCable

I have found similar questions to this but none of the answers fixed the problem. I have an existing project I upgraded from v4.2.5 to 5.1.5. I wanted to add a chatroom using the Site Point tutorial but am having issues with ActionCable. Whenever I start up my server, it crashes with the following error:
/home/ubuntu/workspace/config/routes.rb:39:in `block in <top (required)>': uninitialized constant ActionCable (NameError)
from /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-4.2.5/lib/action_dispatch/routing/route_set.rb:434:in `instance_exec'
from /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-4.2.5/lib/action_dispatch/routing/route_set.rb:434:in `eval_block'
from /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-4.2.5/lib/action_dispatch/routing/route_set.rb:412:in `draw'
from /home/ubuntu/workspace/config/routes.rb:3:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/application/routes_reloader.rb:40:in `each'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/application/routes_reloader.rb:40:in `load_paths'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/application/routes_reloader.rb:16:in `reload!'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/application/routes_reloader.rb:26:in `block in updater'
from /usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-4.2.5/lib/active_support/file_update_checker.rb:75:in `execute'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/application/routes_reloader.rb:27:in `updater'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `run'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/initializable.rb:55:in `block in run_initializers'
from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:347:in `each'
from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:347:in `call'
from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/initializable.rb:54:in `run_initializers'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/application.rb:352:in `initialize!'
from /home/ubuntu/workspace/config/environment.rb:5:in `<top (required)>'
from /home/ubuntu/workspace/config.ru:3:in `require'
from /home/ubuntu/workspace/config.ru:3:in `block in <main>'
from /usr/local/rvm/gems/ruby-2.3.4/gems/rack-1.6.9/lib/rack/builder.rb:55:in `instance_eval'
from /usr/local/rvm/gems/ruby-2.3.4/gems/rack-1.6.9/lib/rack/builder.rb:55:in `initialize'
from /home/ubuntu/workspace/config.ru:in `new'
from /home/ubuntu/workspace/config.ru:in `<main>'
from /usr/local/rvm/gems/ruby-2.3.4/gems/rack-1.6.9/lib/rack/builder.rb:49:in `eval'
from /usr/local/rvm/gems/ruby-2.3.4/gems/rack-1.6.9/lib/rack/builder.rb:49:in `new_from_string'
from /usr/local/rvm/gems/ruby-2.3.4/gems/rack-1.6.9/lib/rack/builder.rb:40:in `parse_file'
from /usr/local/rvm/gems/ruby-2.3.4/gems/rack-1.6.9/lib/rack/server.rb:300:in `build_app_and_options_from_config'
from /usr/local/rvm/gems/ruby-2.3.4/gems/rack-1.6.9/lib/rack/server.rb:209:in `app'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/commands/server.rb:61:in `app'
from /usr/local/rvm/gems/ruby-2.3.4/gems/rack-1.6.9/lib/rack/server.rb:337:in `wrapped_app'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/commands/server.rb:139:in `log_to_stdout'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/commands/server.rb:78:in `start'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:80:in `block in server'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `server'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
I already manually created the following files to set up ActionCable:
# app/channels/application_cable/channel.rb
module ApplicationCable
class Channel < ActionCable::Channel::Base
end
end
and
# app/channels/application_cable/connection.rb
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
self.current_user = find_verified_user
logger.add_tags 'ActionCable', current_user.email
end
protected
def find_verified_user # this checks whether a user is authenticated with devise
if verified_user = env['warden'].user
verified_user
else
reject_unauthorized_connection
end
end
end
end
I have tried requiring both "action_cable" and "action_cable/engine" in the top of my config/application.rb, but it gives me the following errors:
# including "require 'action_cable/engine' "
/home/ubuntu/workspace/config/application.rb:4:in `require': cannot load such file -- action_cable/engine (LoadError)
from /home/ubuntu/workspace/config/application.rb:4:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:78:in `require'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:78:in `block in server'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `server'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
and
# including "require 'action_cable' "
/home/ubuntu/workspace/config/application.rb:4:in `require': cannot load such file -- action_cable (LoadError)
from /home/ubuntu/workspace/config/application.rb:4:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:78:in `require'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:78:in `block in server'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `server'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
Because Rails 5 is meant to have actioncable pre-loaded, I have not included any gems for it.
My config/routes.rb is:
include SessionsHelper
Rails.application.routes.draw do
[...]
mount ActionCable.server => '/cable'
[...]
end
Issue is fixed- I don't know what happened but the app didn't upgrade properly and wasn't running as 5.1.5 after I tried upgrading it. I had to do it one more time and delete the following line from the config/application.rb : config.active_record.raise_in_transactional_callbacks = true in order to get it working.

Uninitialized constant error on spree upgrade

I am trying to upgrade from spree 0.7 to spree 1.0.7. After successful bundle install I am fetting the following error:
/config/initializers/product_review_ratings.rb:12:in `<class:Config>': uninitialized constant Spree::ProductReviewsRatings::Config::PreferenceAccess (NameError)
from /home/nish/repos/spree/voylla_website_production/config/initializers/product_review_ratings.rb:10:in `<module:ProductReviewsRatings>'
from /home/nish/repos/spree/voylla_website_production/config/initializers/product_review_ratings.rb:2:in `<module:Spree>'
from /home/nish/repos/spree/voylla_website_production/config/initializers/product_review_ratings.rb:1:in `<top (required)>'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/railties-3.1.12/lib/rails/engine.rb:556:in `block (2 levels) in <class:Engine>'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/railties-3.1.12/lib/rails/engine.rb:555:in `each'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/railties-3.1.12/lib/rails/engine.rb:555:in `block in <class:Engine>'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/railties-3.1.12/lib/rails/initializable.rb:30:in `instance_exec'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/railties-3.1.12/lib/rails/initializable.rb:30:in `run'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/railties-3.1.12/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/railties-3.1.12/lib/rails/initializable.rb:54:in `each'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/railties-3.1.12/lib/rails/initializable.rb:54:in `run_initializers'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/railties-3.1.12/lib/rails/application.rb:96:in `initialize!'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/railties-3.1.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/nish/repos/spree/voylla_website_production/config/environment.rb:7:in `<top (required)>'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/polyglot-0.3.4/lib/polyglot.rb:65:in `require'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/polyglot-0.3.4/lib/polyglot.rb:65:in `require'
from /home/nish/repos/spree/voylla_website_production/config.ru:3:in `block in <main>'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/rack-1.3.10/lib/rack/builder.rb:51:in `instance_eval'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/rack-1.3.10/lib/rack/builder.rb:51:in `initialize'
from /home/nish/repos/spree/voylla_website_production/config.ru:in `new'
from /home/nish/repos/spree/voylla_website_production/config.ru:in `<main>'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/rack-1.3.10/lib/rack/builder.rb:40:in `eval'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/rack-1.3.10/lib/rack/builder.rb:40:in `parse_file'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/rack-1.3.10/lib/rack/server.rb:200:in `app'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/railties-3.1.12/lib/rails/commands/server.rb:46:in `app'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/rack-1.3.10/lib/rack/server.rb:304:in `wrapped_app'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/rack-1.3.10/lib/rack/server.rb:254:in `start'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/railties-3.1.12/lib/rails/commands/server.rb:70:in `start'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/railties-3.1.12/lib/rails/commands.rb:54:in `block in <top (required)>'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/railties-3.1.12/lib/rails/commands.rb:49:in `tap'
from /home/nish/.rvm/gems/ruby-1.9.2-p320#spreeTest/gems/railties-3.1.12/lib/rails/commands.rb:49:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
/config/initializers/product_review_ratings.rb
module Spree
module ProductReviewsRatings
class Config
include Singleton
include PreferenceAccess
class << self
def instance
return nil unless ActiveRecord::Base.connection.tables.include?('configurations')
ProductReviewsRatingsConfiguration.find_or_create_by_name("Default product reviews and ratings configuration")
end
end
end
end
end
I tried to google, but could not find anything
PreferenceAccess was removed from Spree 1.0.0 by this commit:
https://github.com/spree/spree/commit/a4a57db941eeb6329ac9a5de64f2175e33a56f95
You can add preference_access.rb to your application in order to bring that functionality back, however, this will most likely lead to something else breaking.
If possible, you may want to consider porting from SpreeProductReviewsRatings to the spree_reviews extension, which currently supports Spree 1.0 - 2.3.0.beta.

uninitialized constant ApplicationController (NameError) - application works fine locally

I've set up a simple application online on a rackspace cloud server but I'm getting the following error message from phusion passenger:
uninitialized constant ApplicationController (NameError)
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:230:in `block in constantize'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:229:in `each'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:229:in `constantize'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/devise-2.2.4/app/controllers/devise_controller.rb:2:in `<top (required)>'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/devise-2.2.4/app/controllers/devise/confirmations_controller.rb:1:in `<top (required)>'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/engine.rb:438:in `each'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/engine.rb:438:in `block in eager_load!'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/engine.rb:436:in `each'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/engine.rb:436:in `eager_load!'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/application/railties.rb:8:in `each'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/application/railties.rb:8:in `all'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/engine.rb:434:in `eager_load!'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `instance_exec'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `run'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/initializable.rb:55:in `block in run_initializers'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `each'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `run_initializers'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/application.rb:136:in `initialize!'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
/var/www/ideamobb.com/config/environment.rb:5:in `<top (required)>'
config.ru:3:in `require'
config.ru:3:in `block in <main>'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.8/helper-scripts/rack-preloader.rb:82:in `eval'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.8/helper-scripts/rack-preloader.rb:82:in `preload_app'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.8/helper-scripts/rack-preloader.rb:127:in `<module:App>'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.8/helper-scripts/rack-preloader.rb:6:in `<module:PhusionPassenger>'
/var/www/.rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.8/helper-scripts/rack-preloader.rb:5:in `<main>'
I'm not sure whats going on here - the application works perfectly fine on my localhost - all the gems are installed, migrations are cleared - so what exactly might be the problem here?
I think you are missing ApplicationController. All other controllers inherit from this class
A simple application_controller.rb
class ApplicationController < ActionController::Base
end
In my case I misspelled "application" in my routes file. Make sure to check your spelling!

Why rails can't find my sweepers?

I have on my controller:
class FormulariosController < ApplicationController
cache_sweeper :campanha_sweeper, :only => [:show]
# actions
end
I've tried to create a directory called /sweepers inside app and it didn't work, I've tried inside models to create a /cache folder(there were a blog using this as example) and it didn't work.
My sweeper looks like this:
class CampanhaSweeper < ActionController::Caching::Sweeper
observe Campanha
def after_update(campanha)
expire_cache_for(campanha)
end
private
def expire_cache_for(campanha)
expire_page(:controller => 'formularios', :action => 'show')
ap "Expired cache for formularios#show in formulariosweeper"
end
end
I get when trying to start the server the following:
/Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.12/lib/action_controller/caching/sweeping.rb:41:in `const_get': uninitialized constant CampanhaSweeper (NameError)
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.12/lib/action_controller/caching/sweeping.rb:41:in `block in cache_sweeper'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.12/lib/action_controller/caching/sweeping.rb:39:in `each'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.12/lib/action_controller/caching/sweeping.rb:39:in `cache_sweeper'
from /Users/thiagomassa/Projects-ginga/ginga-campanhas/app/controllers/formularios_controller.rb:2:in `<class:FormulariosController>'
from /Users/thiagomassa/Projects-ginga/ginga-campanhas/app/controllers/formularios_controller.rb:1:in `<top (required)>'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.12/lib/rails/engine.rb:138:in `block (2 levels) in eager_load!'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.12/lib/rails/engine.rb:137:in `each'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.12/lib/rails/engine.rb:137:in `block in eager_load!'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.12/lib/rails/engine.rb:135:in `each'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.12/lib/rails/engine.rb:135:in `eager_load!'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.12/lib/rails/application.rb:108:in `eager_load!'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.12/lib/rails/application/finisher.rb:41:in `block in <module:Finisher>'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.12/lib/rails/initializable.rb:25:in `instance_exec'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.12/lib/rails/initializable.rb:25:in `run'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.12/lib/rails/initializable.rb:50:in `block in run_initializers'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.12/lib/rails/initializable.rb:49:in `each'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.12/lib/rails/initializable.rb:49:in `run_initializers'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.12/lib/rails/application.rb:134:in `initialize!'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.12/lib/rails/application.rb:77:in `method_missing'
from /Users/thiagomassa/Projects-ginga/ginga-campanhas/config/environment.rb:5:in `<top (required)>'
from /Users/thiagomassa/Projects-ginga/ginga-campanhas/config.ru:3:in `block in <main>'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.2.5/lib/rack/builder.rb:46:in `instance_eval'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.2.5/lib/rack/builder.rb:46:in `initialize'
from /Users/thiagomassa/Projects-ginga/ginga-campanhas/config.ru:1:in `new'
from /Users/thiagomassa/Projects-ginga/ginga-campanhas/config.ru:1:in `<main>'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.2.5/lib/rack/builder.rb:35:in `eval'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.2.5/lib/rack/builder.rb:35:in `parse_file'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.2.5/lib/rack/server.rb:162:in `app'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.2.5/lib/rack/server.rb:253:in `wrapped_app'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.2.5/lib/rack/server.rb:204:in `start'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.12/lib/rails/commands/server.rb:65:in `start'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.12/lib/rails/commands.rb:30:in `block in <top (required)>'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.12/lib/rails/commands.rb:27:in `tap'
from /Users/thiagomassa/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.12/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Why didn't it work? Also, is there any way to expire cache of only a view(of how it's rendered). I'm generating views on the fly and it would be very useful if I could expire the cache of a view that is located at say, views/formularios/a.html.rb
If guys want to know what I'm doing, it's simple. I generate views with forms and when I want to update that view(or it's code) and I'm in production, the view doesn't get updated due to caching so I have to manually reset it's cache everytime I "update" a form.
Thanks.
Did you add the sweepers directory (or where ever you've put the sweeper code) to your autoload_paths in application.rb?

rails upgrade from 1.8.7 to 1.9.2 introduces syntax error

currently using ruby-1.8.7-p302 [ i386 ]
moving to ruby ruby-1.9.2-p0 [ i386 ]
running rails 3.0.0
got the following error after upgrade:
# RAILS_ENV=production rails s
=> Booting WEBrick
=> Rails 3.0.0 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/usr/local/rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/helpers.rb:53:in `class_eval': /usr/local/rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/helpers.rb:54: syntax error, unexpected tLBRACE (SyntaxError)
def {:only=>:after_sign_in_path_for}(*args, &blk)
^
/usr/local/rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/helpers.rb:54: syntax error, unexpected '(', expecting $end
def {:only=>:after_sign_in_path_for}(*args, &blk)
^
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/helpers.rb:53:in `block in helper_method'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/helpers.rb:52:in `each'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/helpers.rb:52:in `helper_method'
from /var/www/html/matcha/app/controllers/application_controller.rb:8:in `<class:ApplicationController>'
from /var/www/html/matcha/app/controllers/application_controller.rb:1:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `block in require'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:227:in `load_dependency'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:346:in `require_or_load'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:491:in `load_missing_constant'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:183:in `block in const_missing'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:181:in `each'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:181:in `const_missing'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing_from_s3_library'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/devise-1.5.3/app/controllers/devise/confirmations_controller.rb:1:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `block in require'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:227:in `load_dependency'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:346:in `require_or_load'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:300:in `depend_on'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:216:in `require_dependency'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/engine.rb:138:in `block (2 levels) in eager_load!'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/engine.rb:137:in `each'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/engine.rb:137:in `block in eager_load!'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/engine.rb:135:in `each'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/engine.rb:135:in `eager_load!'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/application/railties.rb:11:in `each'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/application/railties.rb:11:in `all'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/application.rb:107:in `eager_load!'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/application/finisher.rb:41:in `block in <module:Finisher>'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/initializable.rb:25:in `instance_exec'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/initializable.rb:25:in `run'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/initializable.rb:50:in `block in run_initializers'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/initializable.rb:49:in `each'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/initializable.rb:49:in `run_initializers'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/application.rb:134:in `initialize!'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/application.rb:77:in `method_missing'
from /var/www/html/matcha/config/environment.rb:5:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `block in require'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:in `block in load_dependency'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:591:in `new_constants_in'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:in `load_dependency'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
from /var/www/html/matcha/config.ru:3:in `block in <main>'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.4/lib/rack/builder.rb:46:in `instance_eval'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.4/lib/rack/builder.rb:46:in `initialize'
from /var/www/html/matcha/config.ru:1:in `new'
from /var/www/html/matcha/config.ru:1:in `<main>'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.4/lib/rack/builder.rb:35:in `eval'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.4/lib/rack/builder.rb:35:in `parse_file'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.4/lib/rack/server.rb:162:in `app'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.4/lib/rack/server.rb:253:in `wrapped_app'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.4/lib/rack/server.rb:204:in `start'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands/server.rb:65:in `start'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands.rb:30:in `block in <top (required)>'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands.rb:27:in `tap'
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
the relevant application_controller code:
class ApplicationController < ActionController::Base
include Facebooker2::Rails::Controller
helper :all # include all helpers, all the time
protect_from_forgery
layout :layout_by_resource
before_filter :set_cache_buster
before_filter :current_facebook_user, :only => :after_sign_in_path_for
helper_method :current_facebook_client, :only => :after_sign_in_path_for
...
end
it's barfing on the "helper_method :current_facebook_client, :only => :after_sign_in_path_for", but for the life of me, i can't see what's wrong with the syntax (especially since it worked in 1.8.7.
The method call to helper_method is wrong, helper_method(*meths) takes a variable amount of symbols representing helper names, it does not take an opts hash helper_method(*meths, opts = {})
# from http://api.rubyonrails.org/
helper_method(*meths)
# Declare a controller method as a helper. For example, the
# following makes the current_user controller method available to the view:
class ApplicationController < ActionController::Base
helper_method :current_user, :logged_in?
def current_user
#current_user ||= User.find_by_id(session[:user])
end
def logged_in?
current_user != nil
end
end

Resources