<repo_name>porsamini/Survey<file_sep>/app/helpers/questions_helper.rb
module QuestionsHelper
  def link_to_add_field(name, f, association)
    new_object = f.object.class.reflect_on_association(association).klass.new
    fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
      render("answers/form", :form => builder)
    end
    link_to_function(name, h("add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\")"))
  end
end
<file_sep>/app/models/question.rb
class Question < ActiveRecord::Base
  has_many :answers
  accepts_nested_attributes_for :answers, :reject_if => lambda {|a|a[:content].blank?}, :allow_destroy => true
end
