Integrate MajorityJudgment class
This commit is contained in:
parent
4693e7bf73
commit
c8bfea4898
3 changed files with 16 additions and 4 deletions
8
vote.rb
8
vote.rb
|
|
@ -3,8 +3,7 @@ require 'sinatra'
|
|||
require 'sinatra/activerecord'
|
||||
require 'bcrypt'
|
||||
require 'securerandom'
|
||||
|
||||
#set :database, 'sqlite3:db/vote.sqlite3'
|
||||
require_relative 'mj'
|
||||
|
||||
class Vote < ActiveRecord::Base
|
||||
has_many :candidates
|
||||
|
|
@ -14,6 +13,11 @@ end
|
|||
class Candidate < ActiveRecord::Base
|
||||
belongs_to :vote
|
||||
has_many :ratings
|
||||
|
||||
def mj
|
||||
return MajorityJudgment.new(self.ratings.collect {|r| r.value })
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class User < ActiveRecord::Base
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue