mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-27 10:14:17 +08:00
Add association between repository rows & my modules
This commit is contained in:
parent
ef1ecdd7c7
commit
bb20d2661f
2 changed files with 24 additions and 0 deletions
12
app/models/repository_row_my_module.rb
Normal file
12
app/models/repository_row_my_module.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
class RepositoryRowMyModule < ActiveRecord::Base
|
||||
validates :repository_row, :my_module, presence: true
|
||||
|
||||
# One row can only be assigned once to a specific module
|
||||
validates_uniqueness_of :repository_row_id, :scope => :my_module_id
|
||||
|
||||
belongs_to :assigned_by, foreign_key: 'assigned_by_id', class_name: 'User'
|
||||
belongs_to :repository_row,
|
||||
inverse_of: :repository_row_my_modules
|
||||
belongs_to :my_module,
|
||||
inverse_of: :repository_row_my_modules
|
||||
end
|
12
db/migrate/20170530150200_add_repository_row_my_modules.rb
Normal file
12
db/migrate/20170530150200_add_repository_row_my_modules.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
class AddRepositoryRowMyModules < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :repository_row_my_modules do |t|
|
||||
t.belongs_to :repository_row, index: true
|
||||
t.belongs_to :my_module, index: true
|
||||
t.integer :assigned_by_id, null: false
|
||||
t.timestamps null: true
|
||||
end
|
||||
|
||||
add_foreign_key :repository_row_my_modules, :users, column: :assigned_by_id
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue