references rails inverse_of has_and_belongs_to_many foreign belong association ruby-on-rails ruby-on-rails-3 activerecord multiple-inheritance mixins

ruby-on-rails - inverse_of - rails references



Mezcla en el módulo con attr_accessible, has_one, has_many (1)

¿Puedo hacer algo así en Rails?

module Authored belongs_to :user attr_accessible creation_date end class Line < ActiveRecord::Base include Authored end class Document < ActiveRecord::Base include Authored end class User < ActiveRecord::Base has_many :creations, :class_name => ''Authored'' end

¿O necesito usar una herencia simple, incluso si mis clases Authored tienen jerarquías de clases diferentes?


module Authored extend ActiveSupport::Concern included do belongs_to :user attr_accessible :creation_date end end class Line < ActiveRecord::Base include Authored end class Document < ActiveRecord::Base include Authored end

Para obtener más información sobre ActiveSupport::Concern , http://api.rubyonrails.org/classes/ActiveSupport/Concern.html