Skip to content

Instantly share code, notes, and snippets.

@djsun
Created August 27, 2010 18:24
Show Gist options
  • Save djsun/553904 to your computer and use it in GitHub Desktop.
Save djsun/553904 to your computer and use it in GitHub Desktop.
class ResourceGroup
has_many :resource_entries
end
class ResourceEntry
belongs_to :resource, :polymorphic => true
end
# A type of resource
class Image < ActiveRecord::Base
has_one :resource_entry, :as => :resource
end
# A type of resource
class Document < ActiveRecord::Base
has_one :resource_entry, :as => :resource
end
# A type of resource
class Link < ActiveRecord::Base
has_one :resource_entry, :as => :resource
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment