I am trying to learn how to use a hyperlink in a view to access a custom controller method. I have the following code in my Controller, and I would like to access this with a link_to command in a View. I’m guessing there is something I need to do in the routes file to make the launch_build_file method work? What code should I list in the View to trigger the launch_build_file method?
class ReportsController < ApplicationController
def index
end
def launch_build_file
Process.spawn("ruby #{Rails.root}/lib/build.rb")
end
end
In your routes file suppose you have reports resource,if not then you can use named routes