4

just trying to run migrations in my rails app (rails 4, ruby 2.1.2) and keep getting this error:

superclass must be a Class (Module given) (TypeError) 

here is the stack:

rails g migration createCompany /home/javier/Drivers/app/models/driver.rb:1:in `<top (required)>': superclass must be a Class (Module given) (TypeError) from /home/javier/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:443:in `load' from /home/javier/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:443:in `block in load_file' from /home/javier/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:633:in `new_constants_in' from /home/javier/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:442:in `load_file' from /home/javier/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:342:in `require_or_load' from /home/javier/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:480:in `load_missing_constant' from /home/javier/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:180:in `const_missing' from /home/javier/Drivers/app/admin/driver.rb:1:in `<top (required)>' from /home/javier/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `load' from /home/javier/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `block in load' from /home/javier/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:in `load_dependency' from /home/javier/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `load' from /home/javier/.rvm/gems/ruby-2.1.2/bundler/gems/active_admin-b8e89c747881/lib/active_admin/application.rb:179:in `block in load' from /home/javier/.rvm/gems/ruby-2.1.2/bundler/gems/active_admin-b8e89c747881/lib/active_admin/error.rb:23:in `capture' from /home/javier/.rvm/gems/ruby-2.1.2/bundler/gems/active_admin-b8e89c747881/lib/active_admin/application.rb:179:in `load' from /home/javier/.rvm/gems/ruby-2.1.2/bundler/gems/active_admin-b8e89c747881/lib/active_admin/application.rb:171:in `block in load!' from /home/javier/.rvm/gems/ruby-2.1.2/bundler/gems/active_admin-b8e89c747881/lib/active_admin/application.rb:171:in `each' from /home/javier/.rvm/gems/ruby-2.1.2/bundler/gems/active_admin-b8e89c747881/lib/active_admin/application.rb:171:in `load!' from /home/javier/.rvm/gems/ruby-2.1.2/bundler/gems/active_admin-b8e89c747881/lib/active_admin/application.rb:193:in `routes' from /home/javier/.rvm/gems/ruby-2.1.2/bundler/gems/active_admin-b8e89c747881/lib/active_admin.rb:80:in `routes' from /home/javier/Drivers/config/routes.rb:8:in `block in <top (required)>' from /home/javier/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.4/lib/action_dispatch/routing/route_set.rb:337:in `instance_exec' from /home/javier/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.4/lib/action_dispatch/routing/route_set.rb:337:in `eval_block' from /home/javier/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.4/lib/action_dispatch/routing/route_set.rb:315:in `draw' from /home/javier/Drivers/config/routes.rb:1:in `<top (required)>' from /home/javier/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `load' from /home/javier/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `block in load' from /home/javier/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:in `load_dependency' from /home/javier/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `load' from /home/javier/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/application/routes_reloader.rb:40:in `block in load_paths' from /home/javier/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/application/routes_reloader.rb:40:in `each' from /home/javier/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/application/routes_reloader.rb:40:in `load_paths' from /home/javier/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/application/routes_reloader.rb:16:in `reload!' from /home/javier/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/application/routes_reloader.rb:26:in `block in updater' from /home/javier/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/file_update_checker.rb:75:in `call' from /home/javier/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/file_update_checker.rb:75:in `execute' from /home/javier/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/application/routes_reloader.rb:27:in `updater' from /home/javier/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated' from /home/javier/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/application/finisher.rb:71:in `block in <module:Finisher>' from /home/javier/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/initializable.rb:30:in `instance_exec' from /home/javier/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/initializable.rb:30:in `run' from /home/javier/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/initializable.rb:55:in `block in run_initializers' from /home/javier/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each' from /home/javier/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component' from /home/javier/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from' from /home/javier/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component' from /home/javier/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each' from /home/javier/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `call' from /home/javier/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component' from /home/javier/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each' from /home/javier/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each' from /home/javier/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/initializable.rb:54:in `run_initializers' from /home/javier/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/application.rb:300:in `initialize!' from /home/javier/Drivers/config/environment.rb:5:in `<top (required)>' from /home/javier/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require' from /home/javier/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `block in require' from /home/javier/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:in `load_dependency' from /home/javier/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require' from /home/javier/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/application.rb:276:in `require_environment!' from /home/javier/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:147:in `require_application_and_environment!' from /home/javier/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:133:in `generate_or_destroy' from /home/javier/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:51:in `generate' from /home/javier/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:40:in `run_command!' from /home/javier/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands.rb:17:in `<top (required)>' from bin/rails:4:in `require' from bin/rails:4:in `<main>' 

Driver class:

class Driver < Instructor has_one :status has_many :driver_products has_many :driver_services has_many :services, :through => :driver_services belongs_to :town belongs_to :county belongs_to :country geocoded_by :full_address after_validation :geocode, :on => :update # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable def full_address "#{self.address_line_1}" + "," + "#{self.address_line_2}" end def full_name "#{first_name}" + " " + "#{second_name}" end end 

Updated gems and also try to run:

rails g devise Instructor but keep getting the same error.

*Note: I have dropped table Instructor

Any ideas anyone? Cheers J

4
  • From your stacktrace: from /home/javier/Drivers/app/admin/driver.rb:1:in `<top (required)>'. Could you show this file? My guess is you have class Admin::Driver < ActiveRecord instead of class Admin::Driver < ActiveRecord::Base Commented Aug 14, 2014 at 22:40
  • 1
    If you dropped Instructor model, then no surprise you're getting this error, as your class inherit from non-existing model (if you have a folder instructor anywhere in your load path, rails creates a module with that name). If you only dropped it temporarily, change Instructor to ActiveRecord::Base, recreate the model and put it back. Commented Aug 14, 2014 at 22:51
  • 1
    @BroiSatse that helped, just having a number of other issues now. Since this is a branch of a master I will revert back to master and instead of deleting Instructor I will try modifying it. Cheers again Commented Aug 14, 2014 at 23:00
  • Good idea, it will be much simpler. :) Commented Aug 14, 2014 at 23:01

1 Answer 1

1

When my migration code was like this:

class AddSalePriceToSpreeVariants < SpreeExtension::Migration def change add_column :spree_variants, :sale_price, :decimal, precision: 8, scale: 2 end end 

I got the same error, Then I added rails version [6.0] in the first line of the code something like this:-

class AddSalePriceToSpreeVariants < SpreeExtension::Migration[6.0] def change add_column :spree_variants, :sale_price, :decimal, precision: 8, scale: 2 end end 

Error got resolved...

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.