Class: Annotot::Annotation
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Annotot::Annotation
- Defined in:
- app/models/annotot/annotation.rb
Class Method Summary collapse
-
.retrieve_by_id_or_uuid(identifier) ⇒ Object
Used to differentiate between a numeric id and a uuid.
Class Method Details
.retrieve_by_id_or_uuid(identifier) ⇒ Object
Used to differentiate between a numeric id and a uuid. Rails will trim a uuid with leading numbers eg ‘123a’.to_i => 123
12 13 14 15 16 17 18 |
# File 'app/models/annotot/annotation.rb', line 12 def self.retrieve_by_id_or_uuid(identifier) if identifier =~ /\A\d+\z/ find_by(id: identifier) else find_by(uuid: identifier) end end |