Skip to content

Instantly share code, notes, and snippets.

@r38y
Created February 3, 2010 18:03
Show Gist options
  • Save r38y/293833 to your computer and use it in GitHub Desktop.
Save r38y/293833 to your computer and use it in GitHub Desktop.
class Comment
include MongoMapper::Document
key :poll_id, Integer, :required => true, :index => true
key :name, String, :required => true
key :email, String, :required => true
key :body, String, :required => true
timestamps!
def poll
Poll.find(poll_id)
end
def poll=(poll)
self.poll_id = poll.id unless poll.blank?
end
end
class Poll < ActiveRecord::Base
def comments
Comment.find_all_by_poll_id(id)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment