Skip to content

Instantly share code, notes, and snippets.

@workmad3
Forked from codespectator/gist:1373025
Created November 17, 2011 12:24
Show Gist options
  • Save workmad3/1373026 to your computer and use it in GitHub Desktop.
Save workmad3/1373026 to your computer and use it in GitHub Desktop.
class User
include Mongoid::Document
field :email, :type => String
end
require 'lib/test/test'
User.send :include, Test::User
ree-1.8.7-2011.03 :005 > Card.new
=> #<Card _id: 4ec4f9ff31ef62a8ee000003>
ree-1.8.7-2011.03 :001 > u = User.new
=> #<User _id: 4ec4f9ea31ef62a8ee000001, email: nil>
ree-1.8.7-2011.03 :003 > u.cards
NoMethodError: undefined method `cards' for #<User:0x12d3170d0>
class Card
include Mongoid::Document
belongs_to :user
end
module Test
module User
extend ActiveSupport::Concern
included do |base|
base.send(:has_many, :cards)
end
module ClassMethods
end
module InstanceMethods
end
end
require 'lib/test/app/models/card'
require 'lib/test/exts/user'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment