Skip to content

Instantly share code, notes, and snippets.

@cored
Created February 8, 2009 21:02
Show Gist options
  • Save cored/60509 to your computer and use it in GitHub Desktop.
Save cored/60509 to your computer and use it in GitHub Desktop.
# This is a default user class used to activate merb-auth. Feel free to change from a User to
# Some other class, or to remove it altogether. If removed, merb-auth may not work by default.
#
# Don't forget that by default the salted_user mixin is used from merb-more
# You'll need to setup your db as per the salted_user mixin, and you'll need
# To use :password, and :password_confirmation when creating a user
#
# see merb/merb-auth/setup.rb to see how to disable the salted_user mixin
#
# You will need to setup your database and create a user.
class User
include DataMapper::Resource
property :id, Serial
property :login, String
property :first_name, String
property :last_name, String
has n, :questions
has n, :answers
has n, :relevancies
has n, :interests
has n, :questions, :through => :interests
end
class Question
include DataMapper::Resource
property :id, Serial
property :title, String
property :body, String
has n, :answers
has n, :interests
has n, :users, :through => :interests
belongs_to :user
end
class Answer
include DataMapper::Resource
property :id, Serial
property :body, String
has n, :relevancies
belongs_to :question
belongs_to :user
end
class Interest
include DataMapper::Resource
property :user_id, Integer, :key => true
property :question_id, Integer, :key => true
belongs_to :question
belongs_to :user
end
class Relevancy
include DataMapper::Resource
property :id, Serial
property :score, Integer
belongs_to :answer
belongs_to :user
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment