gpt4 book ai didi

ruby-on-rails - 父类(super class)必须是一个类(给定模块)(TypeError)错误 Rails 4 Ruby 2.1.2

转载 作者:行者123 更新时间:2023-12-03 20:20:51 25 4
gpt4 key购买 nike

只是试图在我的 rails 应用程序(rails 4,ruby 2.1.2)中运行迁移并不断收到此错误:

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

这是堆栈:
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>'

驱动类:
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

更新了 gems 并尝试运行:

rails g 设计 Instructor 但不断收到相同的错误。

*注意:我已经删除了表教练

有什么想法吗?
干杯
Ĵ

最佳答案

当我的迁移代码是这样的:

class AddSalePriceToSpreeVariants < SpreeExtension::Migration
def change
add_column :spree_variants, :sale_price, :decimal, precision: 8, scale: 2
end
end
我得到了同样的错误,
然后我添加了 rails 版本 [6.0] 在代码的第一行是这样的: -
class AddSalePriceToSpreeVariants < SpreeExtension::Migration[6.0]
def change
add_column :spree_variants, :sale_price, :decimal, precision: 8, scale: 2
end
end
错误已解决...

关于ruby-on-rails - 父类(super class)必须是一个类(给定模块)(TypeError)错误 Rails 4 Ruby 2.1.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25318650/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com