Cross Reference: ontology_version.rb
xref
: /
ontohub
/
app
/
models
/
ontology_version.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
ontology_version.rb revision e4efbc496f9c7ae337188776b9ba571ce89984d9
class
OntologyVersion
<
ActiveRecord
::
Base
include
OntologyVersion
::
Async
include
OntologyVersion
::
Download
include
OntologyVersion
::
Parsing
belongs_to
:
user
belongs_to
:
ontology
, :
counter_cache
=> :
versions_count
mount_uploader
:
raw_file
,
OntologyUploader
mount_uploader
:
xml_file
,
OntologyUploader
attr_accessible
:
raw_file
, :
source_uri
validate
:
raw_file_xor_source_uri
validate
:
raw_file_size_maximum
validates_format_of
:
source_uri
,
:
with
=>
URI
::
regexp
(
ALLOWED_URI_SCHEMAS
)
, :
if
=> :
source_uri
?
scope
:
latest
,
order
(
'id DESC'
)
protected
def
raw_file_xor_source_uri
if
!
(
raw_file.blank
? ^
source_uri.blank
?)
errors.add
:
source_uri
,
'Specify either a source file or URI.'
end
end
def
raw_file_size_maximum
if
raw_file.size
>
10.megabytes.to
_i
errors.add
:
raw_file
,
'The maximum file size is 10M.'
end
end
end