forked from bofh/fetsite
AutoCommit Don Jul 30 00:03:02 CEST 2015
This commit is contained in:
5
app/models/survey.rb
Normal file
5
app/models/survey.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
module Survey
|
||||
def self.table_name_prefix
|
||||
'survey_'
|
||||
end
|
||||
end
|
||||
5
app/models/survey/answer.rb
Normal file
5
app/models/survey/answer.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class Survey::Answer < ActiveRecord::Base
|
||||
belongs_to :choice, class_name: 'Survey::Choice'
|
||||
belongs_to :user
|
||||
# attr_accessible :title, :body
|
||||
end
|
||||
5
app/models/survey/choice.rb
Normal file
5
app/models/survey/choice.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class Survey::Choice < ActiveRecord::Base
|
||||
belongs_to :question, class_name: 'Survey::Question'
|
||||
attr_accessible :picture, :sort, :text
|
||||
has_many :answers, class_name: 'Survey::Answer'
|
||||
end
|
||||
16
app/models/survey/question.rb
Normal file
16
app/models/survey/question.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
class Survey::Question < ActiveRecord::Base
|
||||
attr_accessible :text, :title, :typ, :choice_ids
|
||||
belongs_to :parent, polymorphic: true
|
||||
has_many :choices
|
||||
has_many :answers, through: :choices
|
||||
def add_yesno_choices
|
||||
c=Survey::Choice.new(title: "Ja")
|
||||
c.save
|
||||
this.choices << c
|
||||
c=Survey::Choice.new(title: "Nein")
|
||||
c.save
|
||||
this.choices << c
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user