Skip to content

Instantly share code, notes, and snippets.

@dalizard
Created May 29, 2011 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dalizard/998164 to your computer and use it in GitHub Desktop.
Save dalizard/998164 to your computer and use it in GitHub Desktop.
class Icon
include Mongoid::Document
field :tiny, type: Hash
field :small, type: Hash
field :medium, type: Hash
field :large, type: Hash
has_many :categories
end
class Category
include Mongoid::Document
field :name, type: String
field :title, type: String
field :keywords, type: Array
field :description, type: String
belongs_to :icon
end
irb(main):001:0> Category.first.icon
=> nil
irb(main):002:0> Category.first.icon=Icon.first
=> #<Icon _id: 4de2c203f9b01648a1000027, _type: nil, tiny: {"x"=>192, "y"=>100, "width"=>12, "height"=>17}, small: {"x"=>192, "y"=>67, "width"=>23, "height"=>33}, medium: {"x"=>0, "y"=>67, "width"=>32, "height"=>47}, large: {"x"=>0, "y"=>0, "width"=>46, "height"=>65}>
irb(main):003:0> Category.first.icon
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment