AutoCommit Don Jul 30 02:03:02 CEST 2015
This commit is contained in:
@@ -13,10 +13,11 @@ class Survey::Question < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def do_answer(choice_ids, user)
|
||||
self.answers.where(user_id: user.id).each {|a| a.delete}
|
||||
choice_ids.each do |c|
|
||||
cid=choice_ids.map{|c|c.to_i}
|
||||
Survey::Answer.where(user_id: user.id, choice_id: self.choice_ids).delete_all
|
||||
cid.each do |c|
|
||||
if self.choice_ids.include?(c)
|
||||
a=Survey::Answer.new(user_id: user.id, choice_id: c)
|
||||
a=Survey::Answer.new(user_id: user.id, choice_id: c.to_i)
|
||||
a.save
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user