Rails superclass mismatch error with two controllers - ruby-on-rails

I have two controllers
one is defined as
class Admin::Businesses::DealsController < AdminController
it is located at app/controllers/admin/businesses/deals_controller.rb
the other
class Admin::DealsController < AdminController
is located at app/controllers/admin/deals_controller.rb
Everything works find in development env but When I push to heroku and the app loads in production env it gives me this error
/app/app/controllers/businesses/deals_controller.rb:1:in `<top (required)>': superclass mismatch for class DealsController (TypeError)
related lines from my routes.rb look like this
namespace 'admin' do
resources :deals do
end
resources :businesses do
resources :deals, module: "businesses"
end
end
Why is it giving me this error, due to same name of controllers ? or super class mismatch ? How can I fix this. I want two controllers for deals one under admin and the other under admin/businesses for business specific actions.
Here is the full stack trace when trying to run the app locally in prod env using
rails s -e production
/home/abid/Projects/vocallocal/app/controllers/admin/businesses/deals_controller.rb:1: warning: toplevel constant Businesses referenced by Admin::Businesses
Exiting
/home/abid/Projects/vocallocal/app/controllers/businesses/deals_controller.rb:1:in `<top (required)>': superclass mismatch for class DealsController (TypeError)
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `block in require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:359:in `require_or_load'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:313:in `depend_on'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:225:in `require_dependency'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/engine.rb:438:in `each'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/engine.rb:438:in `block in eager_load!'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/engine.rb:436:in `each'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/engine.rb:436:in `eager_load!'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `block in run_initializers'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/abid/Projects/vocallocal/config/environment.rb:5:in `<top (required)>'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `block in require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
from /home/abid/Projects/vocallocal/config.ru:4:in `block in <main>'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
from /home/abid/Projects/vocallocal/config.ru:1:in `new'
from /home/abid/Projects/vocallocal/config.ru:1:in `<main>'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands/server.rb:46:in `app'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands/server.rb:70:in `start'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:55:in `block in <top (required)>'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:50:in `tap'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Thanks

The problem is that your admin namespace in your routes is conflicting with your admin module in your class hierarchy. The details about why this is causing that specific error are complicated, but are explained in more detail at http://code.dblock.org/warning-toplevel-constant-xyz-referenced-adminxyz
The simplest solution is to rename one of your admins, probably the class name, to anything else.

Related

How to fix Circular dependency detected while autoloading constant error in rails?

I've created multiple rails application from scratch, but somehow I'm not able fix Circular dependency error. For reproducing the error, I created new app with following commands,
rails new circular_test -d mysql
cd circular_test
rails g model MyImage
rails g scaffold MachineImage
rm db/migrate/20170419063916_create_my_image.rb
rails db:create
rails db:migrate
After this I edited the models, which are as follows,
app/models/machine_image.rb
class MachineImage < ApplicationRecord
AVAILABLE_FLAVORS = { "MyImage" => MyImage}
end
app/models/my_image.rb
class MyImage < MachineImage
end
Everything else was left with default setting. Nothing was changed. Note that, MyImage is inheriting from MachineImage, instead of ApplicationRecord. When I ran this application in development environment, everything works. But when I run the application in production mode (I made sure db:create & db:migrate is done for prod environment as well),
RAILS_ENV=production rails s
I get following error on running above command,
=> Booting Puma
=> Rails 5.0.2 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
Exiting
/Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:509:in `load_missing_constant': Circular dependency detected while autoloading constant MyImage (RuntimeError)
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:203:in `const_missing'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:543:in `load_missing_constant'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:203:in `const_missing'
from /Users/abhigup/Work/git/circular_test/app/models/machine_image.rb:2:in `<class:MachineImage>'
from /Users/abhigup/Work/git/circular_test/app/models/machine_image.rb:1:in `<top (required)>'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `require'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `block in require'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:259:in `load_dependency'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `require'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:380:in `block in require_or_load'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:37:in `block in load_interlock'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/concurrency/share_lock.rb:150:in `exclusive'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies/interlock.rb:11:in `loading'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:37:in `load_interlock'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:358:in `require_or_load'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:511:in `load_missing_constant'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:203:in `const_missing'
from /Users/abhigup/Work/git/circular_test/app/models/my_image.rb:1:in `<top (required)>'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `require'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `block in require'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:259:in `load_dependency'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `require'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:380:in `block in require_or_load'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:37:in `block in load_interlock'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/concurrency/share_lock.rb:150:in `exclusive'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies/interlock.rb:11:in `loading'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:37:in `load_interlock'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:358:in `require_or_load'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:336:in `depend_on'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:252:in `require_dependency'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/engine.rb:476:in `block (2 levels) in eager_load!'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/engine.rb:475:in `each'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/engine.rb:475:in `block in eager_load!'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/engine.rb:473:in `each'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/engine.rb:473:in `eager_load!'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/engine.rb:354:in `eager_load!'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/application/finisher.rb:59:in `each'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/application/finisher.rb:59:in `block in <module:Finisher>'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/initializable.rb:30:in `run'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:345:in `each'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:345:in `call'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/application.rb:352:in `initialize!'
from /Users/abhigup/Work/git/circular_test/config/environment.rb:5:in `<top (required)>'
from /Users/abhigup/Work/git/circular_test/config.ru:3:in `require_relative'
from /Users/abhigup/Work/git/circular_test/config.ru:3:in `block in <main>'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/rack-2.0.1/lib/rack/builder.rb:55:in `instance_eval'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/rack-2.0.1/lib/rack/builder.rb:55:in `initialize'
from /Users/abhigup/Work/git/circular_test/config.ru:in `new'
from /Users/abhigup/Work/git/circular_test/config.ru:in `<main>'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/rack-2.0.1/lib/rack/builder.rb:49:in `eval'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/rack-2.0.1/lib/rack/builder.rb:49:in `new_from_string'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/rack-2.0.1/lib/rack/builder.rb:40:in `parse_file'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/rack-2.0.1/lib/rack/server.rb:318:in `build_app_and_options_from_config'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/rack-2.0.1/lib/rack/server.rb:218:in `app'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/server.rb:59:in `app'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/rack-2.0.1/lib/rack/server.rb:353:in `wrapped_app'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/rack-2.0.1/lib/rack/server.rb:282:in `start'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/server.rb:79:in `start'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:90:in `block in server'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:85:in `tap'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:85:in `server'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands.rb:18:in `<top (required)>'
from /Users/abhigup/Work/git/circular_test/bin/rails:9:in `require'
from /Users/abhigup/Work/git/circular_test/bin/rails:9:in `<top (required)>'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `load'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `call'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/client/command.rb:7:in `call'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/client.rb:30:in `run'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/spring-2.0.1/bin/spring:49:in `<top (required)>'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `load'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `<top (required)>'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
from /Users/abhigup/Work/git/circular_test/bin/spring:15:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
I was able to solve the problem by making config.eager_load = false in production.rb, but that is not ideal way to solve this issue. To addon, in my previous application I had similar structure, but it works flawlessly in production mode. Only difference is, that it is using SQLite. Is MySQL creating issue with this kind of structure? If not, What is the ideal way to solve this issue?
Note: I've tried looked into this, but it doesn't apply to me. As this error is related to load_missing_constant.
Ruby version: 2.2.2
Rails version: 5.0.2
OS: macOS Sierra 10.12.4
MySQL version: 5.7.17 Homebrew
Update: I found this article, which talks about possible reason. But it didn't specify, why the logic fails only when I try to use MySQL.
I would say that superclass shouldn't really know about sublclasses, however if you have to do so, in your specific case instead of having a constant AVAILABLE_FLAVORS, make it a class method:
def self.available_flavors
{ "MyImage" => MyImage}
end
This method won't be called when loading the class, then no circular dependency is there.

Circular dependency on nested concern

Any got any idea why, on my production server I can't use nested concerns in model?
I have a model Landing
class Landing < ActiveRecord::Base
include Claimable
end
and concern
module Claimable
extend ActiveSupport::Concern
end
Everything is working fine, but Claimable is stricly Landing logic so I would like to put it a nested route
class Landing < ActiveRecord::Base
include Landing::Claimable
end
and
module Landing::Claimable
extend ActiveSupport::Concern
end
This is working on my developement machine (OSX Yosemite), but when I deploy to a Linux production server I receive error:
/home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:492:in `load_missing_constant': Circular dependency detected while autoloading constant Landing::Claimable (RuntimeError)
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:184:in `const_missing'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/app/models/landing.rb:20:in `<class:Landing>'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/app/models/landing.rb:18:in `<top (required)>'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:360:in `require_or_load'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:494:in `load_missing_constant'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:184:in `const_missing'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/app/models/concerns/landing/claimable.rb:1:in `<top (required)>'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:360:in `require_or_load'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:317:in `depend_on'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:233:in `require_dependency'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:472:in `block (2 levels) in eager_load!'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:471:in `each'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:471:in `block in eager_load!'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:469:in `each'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:469:in `eager_load!'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:346:in `eager_load!'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/application/finisher.rb:56:in `each'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `instance_exec'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `run'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:55:in `block in run_initializers'
from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each'
from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `call'
from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:54:in `run_initializers'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/application.rb:352:in `initialize!'
from /home/app/app/current/config/environment.rb:5:in `<top (required)>'
from /home/app/app/current/config.ru:3:in `require'
from /home/app/app/current/config.ru:3:in `block in <main>'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in `instance_eval'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in `initialize'
from /home/app/app/current/config.ru:1:in `new'
from /home/app/app/current/config.ru:1:in `<main>'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/rack/adapter/loader.rb:33:in `eval'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/rack/adapter/loader.rb:33:in `load'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/rack/adapter/loader.rb:42:in `for'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/controllers/controller.rb:170:in `load_adapter'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/controllers/controller.rb:74:in `start'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/runner.rb:200:in `run_command'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/runner.rb:156:in `run!'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/bin/thin:6:in `<top (required)>'
from /home/app/app/releases/68f6492bb01f28373b95f26f34b609fdb99dc9cd/vendor/bundle/bin/thin:16:in `load'
from /home/app/app/releases/68f6492bb01f28373b95f26f34b609fdb99dc9cd/vendor/bundle/bin/thin:16:in `<main>'
This usually has to do with your config.eager_load settings on your application. You have a different setting in the production environment from the development one, which is perfectly normal and the intended use, but that's why you experience different behaviors from development to production.
As a possible solution, I suggest you avoid using the one-line namespaced class definition and change it to multiple lines instead.
Try changing:
module Landing::Claimable
end
to:
module Landing
module Claimable
end
end

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.

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?

ActiveAdmin Comment model not working properly

I created a blog by following the Getting Started with Rails precisely. And then I following the tutorial here to try ActiveAdmin: http://activeadmin.info/documentation.html.
It's working fine for the Post and Tag models (I logged in and created/add/edited stuff) but not the Comment model.
rails generate active_admin:resource Comment
create app/admin/comments.rb
Then when I try to start the server I get this:
rails server=> Booting WEBrick
=> Rails 3.0.7 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server Exiting /usr/local/lib/ruby/gems/1.9.1/gems/activeadmin-0.2.2/lib/active_admin/namespace.rb:116:in
`find_or_build_resource': Tried to
register Comment as Comment but
already registered to Comment
(ActiveAdmin::ResourceMismatchError)
from
/usr/local/lib/ruby/gems/1.9.1/gems/activeadmin-0.2.2/lib/active_admin/namespace.rb:45:in
`register' from
/usr/local/lib/ruby/gems/1.9.1/gems/activeadmin-0.2.2/lib/active_admin.rb:141:in
`register' from
/Users/myusername/Projects/RoR/blog/app/admin/comments.rb:1:in
`<top (required)>' from
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:235:in
`load' from
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:235:in
`block in load' from
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in
`block in load_dependency' from
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:596:in
`new_constants_in' from
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in
`load_dependency' from
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:235:in
`load' from
/usr/local/lib/ruby/gems/1.9.1/gems/activeadmin-0.2.2/lib/active_admin.rb:185:in
`block in load!' from
/usr/local/lib/ruby/gems/1.9.1/gems/activeadmin-0.2.2/lib/active_admin.rb:185:in
`each' from
/usr/local/lib/ruby/gems/1.9.1/gems/activeadmin-0.2.2/lib/active_admin.rb:185:in
`load!' from
/usr/local/lib/ruby/gems/1.9.1/gems/activeadmin-0.2.2/lib/active_admin.rb:212:in
`routes' from
/Users/myusername/Projects/RoR/blog/config/routes.rb:2:in
`block in <top (required)>' from
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.7/lib/action_dispatch/routing/route_set.rb:233:in
`instance_exec' from
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.7/lib/action_dispatch/routing/route_set.rb:233:in
`draw' from
/Users/myusername/Projects/RoR/blog/config/routes.rb:1:in
`<top (required)>' from
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:235:in
`load' from
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:235:in
`block in load' from
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in
`block in load_dependency' from
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:596:in
`new_constants_in' from
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in
`load_dependency' from
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:235:in
`load' from
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:127:in `block in reload_routes!' from
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:127:in `each' from
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:127:in `reload_routes!' from
/usr/local/lib/ruby/gems/1.9.1/gems/activeadmin-0.2.2/lib/active_admin.rb:123:in
`block in setup' from
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/callbacks.rb:420:in
`_run_prepare_callbacks' from
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.7/lib/action_dispatch/middleware/callbacks.rb:40:in
`initialize' from
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.7/lib/action_dispatch/middleware/stack.rb:33:in
`new' from
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.7/lib/action_dispatch/middleware/stack.rb:33:in
`build' from
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.7/lib/action_dispatch/middleware/stack.rb:79:in
`block in build' from
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.7/lib/action_dispatch/middleware/stack.rb:79:in
`each' from
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.7/lib/action_dispatch/middleware/stack.rb:79:in
`inject' from
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.7/lib/action_dispatch/middleware/stack.rb:79:in
`build' from
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:162:in `app' from
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application/finisher.rb:35:in
`block in <module:Finisher>' from
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `instance_exec' from
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `run' from
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/initializable.rb:50:in `block in run_initializers' from
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/initializable.rb:49:in `each' from
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/initializable.rb:49:in `run_initializers' from
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:134:in `initialize!' from
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:77:in
`method_missing' from
/Users/myusername/Projects/RoR/blog/config/environment.rb:5:in
`<top (required)>' from
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in
`require' from
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in
`block in require' from
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in
`block in load_dependency' from
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:596:in
`new_constants_in' from
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in
`load_dependency' from
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in
`require' from
/Users/myusername/Projects/RoR/blog/config.ru:3:in
`block in <main>' from
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib/rack/builder.rb:46:in
`instance_eval' from
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib/rack/builder.rb:46:in
`initialize' from
/Users/myusername/Projects/RoR/blog/config.ru:1:in
`new' from
/Users/myusername/Projects/RoR/blog/config.ru:1:in
`<main>' from
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib/rack/builder.rb:35:in
`eval' from
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib/rack/builder.rb:35:in
`parse_file' from
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib/rack/server.rb:162:in
`app' from
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib/rack/server.rb:248:in
`wrapped_app' from
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib/rack/server.rb:213:in
`start' from
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/commands/server.rb:65:in `start' from
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/commands.rb:30:in
`block in <top (required)>' from
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/commands.rb:27:in
`tap' from
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/commands.rb:27:in
`<top (required)>' from
script/rails:6:in `require' from
script/rails:6:in `<main>'
Your help would be appreciated.
Look like a bug (ActiveAdmin has it's own built-in Comment model/class already): https://github.com/gregbell/active_admin/issues/64
A possible workaround could be to give your Comment model a different name within in app/admin/comments.rb:
ActiveAdmin.register Comment, :as => "PostComment" do
try this
run in terminal
rails g active_admin:resource ActiveAdmin::Comment
add a following lines in
app/admin/active_admin_comment.rb
ActiveAdmin.register ActiveAdmin::Comment, :as => "Comment" do
end
after that edit config/initializers/active_admin
[...]
config.comments_registration_name = "OldComment"
config.show_comments_in_menu = false
[...]
And now you have opportunity to customize a comments in app/admin/active_admin_comment.rb
but i still didn't find solution to add :update and :destroy actions
I had the same problem with version 1.0.0.pre, but thankfully, you can suppress ActiveAdmin comments altogether with a config in active_admin.rb then you don't have to alias your own Comment model anymore as mentioned above.
config/initializers/active_admin.rb
...
# == Admin Comments
#
# This allows your users to comment on any resource registered with Active Admin.
#
# You can completely disable comments:
config.allow_comments = false
#
It's also listed in the docs: https://github.com/gregbell/active_admin/blob/master/docs/1-general-configuration.md#comments
Dylan's answer is a great start. In addition to his, I needed to overwrite the controller resource/collection methods.
app/admin/comments.rb
ActiveAdmin.register Comment, as: 'QuestionComment' do
controller do
defaults resource_class: Comment, collection_name: 'comments', instance_name: 'comment'
end
end
Basically, you're just overwriting the defaults of inherited resource controller (https://github.com/josevalim/inherited_resources#overwriting-defaults)
(yes, this is still an issue in 2014 even in the 1.0.0 prerelease version, but it appears that they want to fix it from reading the github issues)

Resources