定义各model之间的关系

This commit is contained in:
sw 2015-01-08 14:41:28 +08:00
parent c9de30bd83
commit 4c6ade4c08
6 changed files with 59 additions and 1 deletions

View File

@ -1,3 +1,5 @@
class PollAnswers < ActiveRecord::Base
attr_accessible :answer_position, :answer_text, :poll_questions_id
belongs_to :poll_questions
end

View File

@ -1,3 +1,5 @@
class PollQuestions < ActiveRecord::Base
attr_accessible :is_necessary, :polls_id, :question_title, :question_type
belongs_to :polls
end

View File

@ -1,3 +1,6 @@
class PollUser < ActiveRecord::Base
attr_accessible :poll_id, :user_id
belongs_to :polls
belongs_to :user
end

View File

@ -1,3 +1,7 @@
class PollVotes < ActiveRecord::Base
attr_accessible :poll_answers_id, :poll_questions_id, :user_id, :vote_text
belongs_to :poll_answers
belongs_to :poll_questions
belongs_to :user
end

View File

@ -1,3 +1,5 @@
class Polls < ActiveRecord::Base
attr_accessible :closed_at, :polls_group_id, :polls_name, :polls_status, :polls_type, :published_at, :user_id
belongs_to :user
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20141231085350) do
ActiveRecord::Schema.define(:version => 20150108035338) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -790,6 +790,51 @@ ActiveRecord::Schema.define(:version => 20141231085350) do
t.integer "project_id"
end
create_table "poll_answers", :force => true do |t|
t.integer "poll_questions_id"
t.text "answer_text"
t.integer "answer_position"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "poll_questions", :force => true do |t|
t.string "question_title"
t.integer "question_type"
t.integer "is_necessary"
t.integer "polls_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "poll_users", :force => true do |t|
t.integer "user_id"
t.integer "poll_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "poll_votes", :force => true do |t|
t.integer "user_id"
t.integer "poll_questions_id"
t.integer "poll_answers_id"
t.text "vote_text"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "polls", :force => true do |t|
t.string "polls_name"
t.string "polls_type"
t.integer "polls_group_id"
t.integer "polls_status"
t.integer "user_id"
t.datetime "published_at"
t.datetime "closed_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "praise_tread_caches", :force => true do |t|
t.integer "object_id", :null => false
t.string "object_type"