Most proper way to use inherited classes with shared scopes in Mongo?

Posted by Trip on Stack Overflow See other posts from Stack Overflow or by Trip
Published on 2012-06-30T21:12:39Z Indexed on 2012/06/30 21:15 UTC
Read the original article Hit count: 157

Filed under:
|
|

I have the TestVisual class that is inherited by the Game class :

class TestVisual < Game
  include MongoMapper::Document  
end

class Game
  include MongoMapper::Document         

  belongs_to :maestra  

  key :incorrect,         Integer
  key :correct,           Integer
  key :time_to_complete,  Integer

  key :maestra_id, ObjectId

  timestamps!

end

As you can see it belongs to Maestra.

So I can do Maestra.first.games

But I can not to Maestra.first.test_visuals

Since I'm working specifically with TestVisuals, that is ideally what I would like to pull.

Is this possible with Mongo. If it isn't or if it isn't necessary, is there any other better way to reach the TestVisual object from Maestra and still have it inherit Game ?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about mongodb