Group, This might very well be Rails 102 stuff, but it''s doing my little head in. 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'') end 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: <pre> undefined local variable or method `method_to_run'' for #<#<Class: 0x46c3248>:0x46c1808> </pre> Jason -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Reference on link_to here: http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to :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 for :method. I suggest you define a controller and invoke one of its methods through the link. Example: link_to "Feature", :controller => "mycontroller", :action => "method_to_run" On Tue, Sep 14, 2010 at 9:29 AM, Jason N <freezingkiwis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Group, > > This might very well be Rails 102 stuff, but it''s doing my little head > in. > > 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'') > end > > 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: > > <pre> > undefined local variable or method `method_to_run'' for #<#<Class: > 0x46c3248>:0x46c1808> > </pre> > > > Jason > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Of course, I should have known that :method was for the HTTP method. Thanks. I guess i just need to write the correct routes now. On Sep 14, 4:28 pm, Srikanth Shreenivas <sri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Reference on link_to here:http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#... > > :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 for > :method. > > I suggest you define a controller and invoke one of its methods through the > link. > > Example: > link_to "Feature", :controller => "mycontroller", :action => "method_to_run" > > > > On Tue, Sep 14, 2010 at 9:29 AM, Jason N <freezingki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Group, > > > This might very well be Rails 102 stuff, but it''s doing my little head > > in. > > > 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'') > > end > > > 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: > > > <pre> > > undefined local variable or method `method_to_run'' for #<#<Class: > > 0x46c3248>:0x46c1808> > > </pre> > > > Jason > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscrib e@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.