Created
April 5, 2011 20:22
-
-
Save byroot/904459 to your computer and use it in GitHub Desktop.
This file contains 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
class Recette < AR::Base | |
include Feeds::ModelMixin | |
end | |
class Article < AR::Base | |
include Feeds::ModelMixin | |
end | |
module Feeds | |
module ModelMixin | |
def self.included(base) | |
base.after_create(:create_feed_item) | |
end | |
def create_feed_item | |
model = "Feeds::#{self.class.name}Item".constantize | |
model.create!( | |
:created_at => created_at # etc | |
) | |
end | |
end | |
class Item < AR::Base | |
abstract = true | |
# field created_at | |
end | |
class RecetteItem | |
has_one :recette, :column => :attachable_id | |
end | |
class ArticleItem | |
has_one :article, :column => :attachable_id | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment