added inbox model

This commit is contained in:
nilsding 2014-11-10 23:45:36 +01:00
parent ba71902c27
commit 17db50623a
6 changed files with 41 additions and 1 deletions

4
app/models/inbox.rb Normal file
View File

@ -0,0 +1,4 @@
class Inbox < ActiveRecord::Base
belongs_to :user
has_one :question
end

View File

@ -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/

View File

@ -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

View File

@ -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"

9
test/fixtures/inboxes.yml vendored Normal file
View File

@ -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

View File

@ -0,0 +1,7 @@
require 'test_helper'
class InboxTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end