Req: Method executed in link_to


This might very well be Rails 102 stuff, but it’s doing my little head

Simple request - I want to create a link within my View to fire off a
system call to run an external program.

In this example it’s pretty easy - run a Windows system command that
simply starts something (it’s not what I’m trying to achieve but it’s
an easy debug method):

def method_to_run
system(‘start dir > test.txt’)

How the heck do I link to this method within my View?

A simple <%= link_to feature, :method => method_to_run %> results in
the following error:

undefined local variable or method `method_to_run' for #<#:0x46c1808>


Reference on link_to here:

:method is used for specifying HTTP method such as POST, GET, etc.

The parameter that you are passing (method_to_run) is not a valid value

I suggest you define a controller and invoke one of its methods through

link_to “Feature”, :controller => “mycontroller”, :action =>

Of course, I should have known that :method was for the HTTP method.


I guess i just need to write the correct routes now.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs