11 changed files with 55 additions and 12 deletions
@ -0,0 +1,7 @@
|
||||
class Block < ApplicationRecord |
||||
belongs_to :account |
||||
belongs_to :target_account, class_name: 'Account' |
||||
|
||||
validates :account, :target_account, presence: true |
||||
validates :account_id, uniqueness: { scope: :target_account_id } |
||||
end |
||||
@ -0,0 +1,12 @@
|
||||
class CreateBlocks < ActiveRecord::Migration[5.0] |
||||
def change |
||||
create_table :blocks do |t| |
||||
t.integer :account_id, null: false |
||||
t.integer :target_account_id, null: false |
||||
|
||||
t.timestamps null: false |
||||
end |
||||
|
||||
add_index :blocks, [:account_id, :target_account_id], unique: true |
||||
end |
||||
end |
||||
Loading…
Reference in new issue