transferred Code Ocean from original repository to GitHub
This commit is contained in:
20
app/models/concerns/context.rb
Normal file
20
app/models/concerns/context.rb
Normal file
@ -0,0 +1,20 @@
|
||||
module Context
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
has_many :files, as: :context, class: CodeOcean::File
|
||||
accepts_nested_attributes_for :files
|
||||
end
|
||||
|
||||
def add_file(file_attributes)
|
||||
file = files.create(file_attributes)
|
||||
save
|
||||
file
|
||||
end
|
||||
|
||||
def add_file!(file_attributes)
|
||||
file = files.create!(file_attributes)
|
||||
save!
|
||||
file
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user