Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use content_tag helper

Using content_tag helper helps to avoid manual html generation. It take
care about html safety.
  • Loading branch information...
commit 1cbf61517348c701e08beea41a39f04b35115e6b 1 parent 218e87b
@lest lest authored
Showing with 4 additions and 8 deletions.
  1. +4 −8 lib/nested_form/builder_mixin.rb
View
12 lib/nested_form/builder_mixin.rb
@@ -21,10 +21,9 @@ def link_to_add(*args, &block)
@fields ||= {}
@template.after_nested_form(association) do
model_object = object.class.reflect_on_association(association).klass.new
- output = %Q[<div id="#{association}_fields_blueprint" style="display: none">].html_safe
- output << fields_for(association, model_object, :child_index => "new_#{association}", &@fields[association])
- output.safe_concat('</div>')
- output
+ blueprint = fields_for(association, model_object, :child_index => "new_#{association}", &@fields[association])
+ blueprint_options = {:id => "#{association}_fields_blueprint", :style => 'display: none'}
+ @template.content_tag(:div, blueprint, blueprint_options)
end
@template.link_to(*args, &block)
end
@@ -57,10 +56,7 @@ def fields_for_with_nested_attributes(association_name, *args)
end
def fields_for_nested_model(name, object, options, block)
- output = '<div class="fields">'.html_safe
- output << super
- output.safe_concat('</div>')
- output
+ @template.content_tag(:div, super, :class => 'fields')
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.