Antwort

23
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 

Für weitere Informationen über ActiveSupport::Concern, http://api.rubyonrails.org/classes/ActiveSupport/Concern.html

+1

Genau das, was ich brauchte, Dank :) Scheint, wie es für die has_many in meinem Benutzer nicht funktionieren wird. Wahrscheinlich muss ich damit umgehen, indem ich eine polymorphe Assoziation verwende. –

Verwandte Themen