Class: Template
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Template
- Defined in:
- app/models/template.rb
Overview
Instance Attribute Summary collapse
-
#created_at ⇒ DateTime
When the record was created.
-
#data ⇒ Array
List of Question attributes.
-
#id ⇒ Integer
Unique identifier for Template.
-
#title ⇒ String
Template title.
-
#updated_at ⇒ DateTime
When the record was updated.
Instance Method Summary collapse
-
#data_string ⇒ data
Value as json string.
-
#data_string=(value) ⇒ Object
set data attribute from a JSON string.
Instance Attribute Details
#created_at ⇒ DateTime
Returns when the record was created.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/template.rb', line 17 class Template < ApplicationRecord validates :title, presence: true # set data attribute from a JSON string def data_string=(value) self.data = JSON.try :parse, value end # @return {data} value as json string def data_string data.to_json end end |
#data ⇒ Array
Returns List of Question attributes.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/template.rb', line 17 class Template < ApplicationRecord validates :title, presence: true # set data attribute from a JSON string def data_string=(value) self.data = JSON.try :parse, value end # @return {data} value as json string def data_string data.to_json end end |
#id ⇒ Integer
Returns unique identifier for Template.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/template.rb', line 17 class Template < ApplicationRecord validates :title, presence: true # set data attribute from a JSON string def data_string=(value) self.data = JSON.try :parse, value end # @return {data} value as json string def data_string data.to_json end end |
#title ⇒ String
Returns Template title.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/template.rb', line 17 class Template < ApplicationRecord validates :title, presence: true # set data attribute from a JSON string def data_string=(value) self.data = JSON.try :parse, value end # @return {data} value as json string def data_string data.to_json end end |
#updated_at ⇒ DateTime
Returns when the record was updated.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/template.rb', line 17 class Template < ApplicationRecord validates :title, presence: true # set data attribute from a JSON string def data_string=(value) self.data = JSON.try :parse, value end # @return {data} value as json string def data_string data.to_json end end |
Instance Method Details
#data_string ⇒ data
Returns value as json string.
26 27 28 |
# File 'app/models/template.rb', line 26 def data_string data.to_json end |
#data_string=(value) ⇒ Object
set data attribute from a JSON string
21 22 23 |
# File 'app/models/template.rb', line 21 def data_string=(value) self.data = JSON.try :parse, value end |