Module: CensusHelper

Defined in:
app/helpers/census_helper.rb

Instance Method Summary collapse

Instance Method Details



7
8
9
10
11
12
13
# File 'app/helpers/census_helper.rb', line 7

def link_to_add_fields(name, form, association)
  new_object = form.object.class.reflect_on_association(association).klass.new
  fields = form.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
    render(association.to_s.singularize + "_fields", :form => builder)
  end
  link_to_function(name, h("add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\")"))
end


3
4
5
# File 'app/helpers/census_helper.rb', line 3

def link_to_remove_fields(name, form)
  form.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)")
end