title: Creating RoR Links within Ajax call in .js.erb file
body: <p>I have the following ajax call that activates on button click:</p>
  
  <pre><code>    $.ajax({
  
              url: button_action,
  
              data: {},
  
              type: "POST",
  
              dataType: "json",
  
              success: function( data ) {
  
                  var att = data.attendees
  
                  var attendee_list = "";
  
                  for (i = 0; i &lt; data.attendees.length; i++) {
                      if ( i != att.length-1) {
                          attendee_list += att[i].first_name + " " + att[i].last_name + ", ";
                      }       else {
                          attendee_list += att[i].first_name + " " + att[i].last_name 
                      }
                  }
  
                  att_array.innerHTML = attendee_list;
              }, . . . 
  
          });
  </code></pre>
  
  <p>Now, we see that I'm getting a list of event attendees back from the server in <code>data.attendees</code>. I'm able to get the first and last name of each attendees, and I can just as easily get the id of the attendees with <code>id = att[i].id</code>. Instead of just displaying the name of each attendee, I would like to <em>create a link</em> to that attendees <code>show</code>page using their <code>id</code>. Ideally, I would create a variable <code>full_name = att[i].first_name + " " att[i].last_name</code>and then create a link like</p>
  
  <pre><code>&lt;%#= link_to full_name, user_path(user.id) %&gt;
  </code></pre>
  
  <p>I am aware that this involves taking json or javascript variables and using them in Ruby code, and then outputting Ruby code. Is this possible, and if so, how can I do it?</p>