How do I run Ruby code on a button click?
===

I have a Rails partial, and a Ruby script I want to run when I click a button in the partial. 

How do I do this?

This is the script I want to run - I have it in `<%= %>` tags right now.

     <%= require 'nokogiri'
    
    doc = Nokogiri::HTML(table_string)
    
    doc.xpath('//table//tr').each do |row|
      row.xpath('td').each do |cell|
        print '"', cell.text.gsub("\n", ' ').gsub('"', '\"').gsub(/(\s){2,}/m, '\1'), "\", "
      end
      print "\n"
    end
    %>

I want to have a button that runs that snippet when I click it.
