Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
136 additions
and
11 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
app/active_record/questions_answeroptions_answers/answer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# encoding: utf-8 | ||
class Answer < ActiveRecord::Base | ||
attr_accessible :questions_answer_option_id | ||
belongs_to :place | ||
belongs_to :questions_answer_option | ||
# belongs_to :question, :through => :questions_answer_option | ||
# belongs_to :answer_option, :through => :questions_answer_option | ||
def question | ||
questions_answer_option.question | ||
end | ||
|
||
def answer | ||
questions_answer_option.answer_option | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
app/active_record/questions_answeroptions_answers/answer_option.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# encoding: utf-8 | ||
class AnswerOption < ActiveRecord::Base | ||
attr_accessible :title | ||
has_many :questions_answer_options | ||
end |
6 changes: 6 additions & 0 deletions
6
app/active_record/questions_answeroptions_answers/categories_place.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class CategoriesPlace < ActiveRecord::Base | ||
attr_accessible :place_id, :category_id | ||
belongs_to :category | ||
belongs_to :place | ||
has_many :questions | ||
end |
8 changes: 8 additions & 0 deletions
8
app/active_record/questions_answeroptions_answers/category.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# encoding: utf-8 | ||
class Category < ActiveRecord::Base | ||
attr_accessible :name | ||
has_many :categories_places | ||
has_many :places, :through => :categories_places | ||
has_many :questions, :through => :categories_places | ||
# has_and_belongs_to_many :questions | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# encoding: utf-8 | ||
class Place < ActiveRecord::Base | ||
attr_accessible :address | ||
has_many :answers | ||
end |
6 changes: 6 additions & 0 deletions
6
app/active_record/questions_answeroptions_answers/question.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# encoding: utf-8 | ||
class Question < ActiveRecord::Base | ||
attr_accessible :title | ||
has_many :questions_answer_options | ||
has_many :answer_options, :through => :questions_answer_options | ||
end |
6 changes: 6 additions & 0 deletions
6
app/active_record/questions_answeroptions_answers/questions_answer_option.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# encoding: utf-8 | ||
class QuestionsAnswerOption < ActiveRecord::Base | ||
has_one :answer | ||
belongs_to :question | ||
belongs_to :answer_option | ||
end |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
db/migrate/20120606055539_create_join_table_for_categories_and_places.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CreateTableQuestions < ActiveRecord::Migration | ||
def up | ||
create_table :questions do |t| | ||
t.string :title | ||
end | ||
end | ||
|
||
def down | ||
drop_table :questions | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
db/migrate/20120608084735_create_join_table_for_questions_and_answer_options.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CreateJoinTableForQuestionsAndAnswerOptions < ActiveRecord::Migration | ||
def up | ||
create_table :questions_answer_options do |t| | ||
t.integer :question_id | ||
t.integer :answer_option_id | ||
end | ||
end | ||
|
||
def down | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class CreateTableAnswers < ActiveRecord::Migration | ||
def up | ||
create_table :answers do |t| | ||
t.references :place | ||
t.references :questions_answer_option | ||
end | ||
end | ||
|
||
def down | ||
drop_table :answers | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CreateTableAnswerOptions < ActiveRecord::Migration | ||
def up | ||
create_table :answer_options do |t| | ||
t.string :title | ||
end | ||
end | ||
|
||
def down | ||
drop_table :answer_options | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace :db do | ||
desc "populate Questions model" | ||
task :populate_questions => :environment do | ||
|
||
Question.delete_all | ||
['wifi','toilet','music','smoking','bank card'].each do |item| | ||
Question.create(:title => item) | ||
end | ||
end | ||
end |