app/helpers/template_helper.rb in kindred-0.0.1 vs app/helpers/template_helper.rb in kindred-0.0.2
- old
+ new
@@ -1,12 +1,8 @@
module TemplateHelper
def template(model: nil, collection: nil, target_uuid: nil, &block)
- model_name = if collection.present?
- ActiveModel::Naming.singular(collection.first)
- else
- model
- end
+ model_name = model
@kindred_hash ||= {}
@kindred_hash.merge!({
model_name => {
template: capture(&block),
@@ -21,10 +17,10 @@
def target(object)
"data-target data-target-uuid=" + k_try(object, :uuid).to_s
end
def k_content_tag(element, attribute = nil, object = nil, content_or_options_with_block = nil, options = {}, escape = true, &block)
- content_tag(element, nil, options.merge({data: { attr: attribute, k_uuid: k_try(object, :uuid), val: ""} }))
+ content_tag(element, nil, options.merge({data: { attr: attribute, k_uuid: k_try(object, :uuid), val: object.try(attribute.to_sym)} }))
end
def k_hidden_field_tag(name, value=nil, object=nil, delegate_to=nil, options = {})
hidden_field_tag name, value, options.merge({data: { attr: name, k_uuid: k_try(object, :uuid), val: value } })
end