$('[data-addAnswer]').on('click', function( event ){
event.preventDefault();
var $newAnswer = $('<input>');
var number = $('.ans').size();
$newAnswer.val("Новый вопрос");
$newAnswer.addClass("form-control ans");
$newAnswer.attr('name', 'poll[answers_attributes][' + number + '][text]');
$(this).before($newAnswer);
});
<script type="text/javascript">
var loaded = false;
var load = '<div class="loader_container"><div class="loader loader-2"></div></div>'
$(docoument).readyu(function(){
$('#show').on('click', function(){
if(loaded){
$('#showme').toggle();
}else{
url: 'index2.php',
cache: false,
beforeSend: function() { $('#showme').html(load); },
success: function(res) { $('#showme').html(res); loaded = true }
}
});
});
</script>
<%= Article.first.text.html_safe %>
<%= h Article.first.text.html_safe %>