Superclass mismatch for ActiveRecord::Base subclass

I am trying to figure out a superclass mismatch TypeError exception in
one of my rails projects. Maybe someone can help here. This occurs
when I am attempting to load a file. On the first load, everything is
fine, but on subsequent loads, it gives me this exception. Here is
the pertinent code.

in check.rb
class Check < ActiveRecord::Base
end

in drc.rb
class DRC < Check
def after_initialize
self.name = “DRC”
self.description = “Design Rule Check”
self.global = false
end
end

Then in a controller I load this file in on a specific action.

  load file
  c = check_name.constantize.new
  c.save

The first time I load there are no issues. It creates a new Check
object for me and saves it into the db. Now when I delete the check
from the db and try to run through this code again I get:

superclass mismatch for class DRC

I’m not changing the superclass for DRC. I’m not reading in a
different file. I’m not sure what is going on here. Any thoughts?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs