Reputation: 2159
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.
Upvotes: 0
Views: 5605
Reputation: 21884
Ex:
resources :my_resources do
collection do
get :your_action
end
end
And your link should be something like: link_to "text", your_action_my_resources_path
.
Upvotes: 7