AutoCommit Don Jul 30 01:03:05 CEST 2015

This commit is contained in:
Andreas Stephanides
2015-07-30 01:03:05 +02:00
parent 97df081b33
commit f161d15174
7 changed files with 31 additions and 4 deletions

View File

@@ -10,7 +10,16 @@ class Survey::Question < ActiveRecord::Base
c=Survey::Choice.new(title: "Nein")
c.save
this.choices << c
end
def do_answer(choice_ids, user)
self.answers.where(user_id: user.id).each {|a| a.delete}
choice_ids.each do |c|
if self.choice_ids.include?(c)
a=Survey::Answer.new(user_id: user.id, choice_id: c)
a.save
end
end
end
end