Created
October 4, 2011 13:10
-
-
Save bogn/1261606 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Page | |
include MongoMapper::Document | |
end | |
class ContentPage < Page | |
many :content_blocks #tried :as => :page as well | |
end | |
class ContentBlock | |
include MongoMapper::EmbeddedDocument | |
belongs_to :content_page | |
# tried belongs_to :page | |
# and belongs_to :page, :polymorphic => true | |
# embedded_in :page didn't make any difference | |
key :text, String | |
end | |
p = Page.find('4e42a6c0cb0f3d2bdc00021e') # is a Page | |
c = Page.find('4e42da66cb0f3d51f6000045') # is a ContentPage | |
c.content_blocks | |
# behaves as expected in mmconsole: [#<ContentBlock _id: BSON::ObjectId('4e8afbe0cb0f3d7846000012'), text: "foo">] | |
# but not in rails dev console/app: [] | |
# or production console/app: [{"_id"=>BSON::ObjectId('4e78f6efcb0f3d56e80000a6'), "text"=>"foo"}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment