Last active
December 14, 2015 03:59
-
-
Save chamnap/5024664 to your computer and use it in GitHub Desktop.
Mongoid collection name
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
require 'mongoid' | |
class A | |
end | |
class B | |
end | |
class Book | |
include Mongoid::Document | |
end | |
a_book = A.const_set(:Book, Class.new(Book)) | |
a_book.store_in collection: 'a_books' | |
b_book = B.const_set(:Book, Class.new(Book)) | |
b_book.store_in collection: 'b_books' | |
A::Book.collection_name #:b_books, it should return :a_books, right? | |
B::Book.collection_name #:b_books |
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
require 'mongoid' | |
class A | |
end | |
class B | |
end | |
class Book | |
include Mongoid::Document | |
end | |
a_book = A.const_set(:Book, Class.new(Book)) | |
a_book.store_in collection: 'a_books' | |
A::Book.collection_name #:a_books, need to call this method after set. | |
b_book = B.const_set(:Book, Class.new(Book)) | |
b_book.store_in collection: 'b_books' | |
B::Book.collection_name #:b_books, need to call this method after set. | |
A::Book.collection_name #:a_books, then it displays correctly. | |
B::Book.collection_name #:b_books, the same here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment