From: Damjan Rems Date: 2013-01-10T07:12:31+09:00 Subject: Extending class In Ruby it is possible to extend module, but not class. I am working on a mongoid rails application where one collection(table) is defined like: class User include Mongoid::Document field :username, type: String field :title, type: String end In my scenario somewhere in the future someone would make a gem, which would need to extend User class. I found out that it can be done this way: User::field :signature, type: String User::belongs_to :visit User::embeds_many :roles but it is kinda ugly. Then I realize that extend keyword exists, but it is possible to extend only modules not classes. So this realy nice example would work only if User is a module. class UserForForum extend User field :signature, type: String belongs_to :visit embeds_many :roles end Is there a clear way of extending classes? by TheR -- Posted via http://www.ruby-forum.com/.