Module: DomFor::Record
- Included in:
- DomFor
- Defined in:
- lib/dom_for/record.rb
Overview
Class name: user
ID name: user_1
Data-attributes: data-object-id = 1
Instance Method Summary collapse
-
#dom_for_record(record, attrs = {}, &block) ⇒ String
Creates a div tag with the attributes for the instance of ActiveRecord.
Instance Method Details
#dom_for_record(record, attrs = {}, &block) ⇒ String
Creates a div tag with the attributes for the instance of ActiveRecord
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dom_for/record.rb', line 33 def dom_for_record(record, attrs={}, &block) object_id = dom_id(record) object_class = dom_class(record.class) attrs = attrs.merge(object_id: record.id) if record.persisted? if block_given? content_tag(:div, id: object_id, class: object_class, data: attrs, &block) else tag(:div, id: object_id, class: object_class, data: attrs) end rescue content_tag(:div, &block) end |