i working on a little app to show some pictures. Each picture can be "voted" or "qualified" in a scale of 1 to 5.
The qualification can be done for a logged user only one time.
I need to know the qualification of each image, and what image a user set the vote (and know the value of that vote), so i create this models:
class Voto
include Mongoid::Document
embedded_in :picture
embedded_in :user
field :value, :type => Integer
end
class Picture
include Mongoid::Document
embeds_many :votos
embeds_many :comments
belongs_to :user
...
...
end
class User
include Mongoid::Document
...
...
has_many :pictures
embeds_many :votos
end
But i don't know if this is correct. ¿Can i store the same model (in this case Voto) in two differents documents (Picture and User)?
Any idea how to achieve this?