added inbox model
This commit is contained in:
parent
ba71902c27
commit
17db50623a
|
@ -0,0 +1,4 @@
|
|||
class Inbox < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
has_one :question
|
||||
end
|
|
@ -10,6 +10,7 @@ class User < ActiveRecord::Base
|
|||
has_many :questions, dependent: :destroy
|
||||
has_many :answers, dependent: :destroy
|
||||
has_many :comments, dependent: :destroy
|
||||
has_many :inboxes, dependent: :destroy
|
||||
|
||||
SCREEN_NAME_REGEX = /\A[a-zA-Z0-9_]{1,16}\z/
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
class CreateInboxes < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :inboxes do |t|
|
||||
t.integer :user_id
|
||||
t.integer :question_id
|
||||
t.boolean :new
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
10
db/schema.rb
10
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20141104143648) do
|
||||
ActiveRecord::Schema.define(version: 20141110210154) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -38,6 +38,14 @@ ActiveRecord::Schema.define(version: 20141104143648) do
|
|||
|
||||
add_index "comments", ["user_id", "created_at"], name: "index_comments_on_user_id_and_created_at", using: :btree
|
||||
|
||||
create_table "inboxes", force: true do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "question_id"
|
||||
t.boolean "new"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "questions", force: true do |t|
|
||||
t.string "content"
|
||||
t.boolean "author_is_anonymous"
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
user_id: 1
|
||||
question_id: 1
|
||||
|
||||
two:
|
||||
user_id: 1
|
||||
question_id: 1
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class InboxTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
Reference in New Issue