RailsCasts Pro episodes are now free!

Learn more or hide this

Nitesh's Profile

GitHub User: coffeebite

Comments by Nitesh

Avatar

Thanks. The module inside class was suggested by @rbates himself.

Avatar

I am namespacing my concerns as demonstrated in the tutorial.

I have a class Portrait and a concern Portrait::ToHash defined as

ruby
class Portrait < ActiveRecord::Base
  #my class
end

class Portrait
  module ToHash
    #my methods
  end
end

but I get this error: superclass mismatch for class

The error goes away if I do this:

ruby
class Portrait < ActiveRecord::Base
  module ToHash
    #my methods
  end
end

I have 5 models and I do not need to inherit the class from ActiveRecord::Base when defining the concern in any of the others. Just this one.

Any clues what could be happening?