I am new to ruby on rails and trying to build an internal site to manage several ruby scripts. What I am trying to accomplish; create web page where an user clicks on a link (Execute Analyzer) to execute ruby script (runs in the background - FitAnalyzer.rb). I am having trouble understanding how to route this without redirecting to another web page. Basically need help how to add the correct format to routes.rb. analyzer.html.erb <%= link_to "Execute Analyzer", :controller => ''fit_anlayzer_controller'', :method => ''execute_analyzer'', :popup => true %> fit_analyzer_controller.rb class FitAnalyzerController < ApplicationController def analyzer end def execute_analyzer # Delayed::Job.enqueue(AnalyzerJob.new(params[:id]), 3) # command = ''ruby ~/ruby_scripts/fit_analyzer/FitAnalyzer.rb'' @execute_command = system ''ruby /Users/gsypolt/rubyqa_project/ruby_scripts/fit_analyzer/FitAnalyzer.rb'' flash[:notice] = "Executing FitNesse Analyzer" end end When accessing http://localhost:3000/fit_analyzer/analyzer receiving this message below No route matches {:controller=>"fit_anlayzer_controller", :method=>"execute_analyzer", :popup=>true} I have been learning ruby on rails from lyndia.com and book (rails 3 way). Attachments: http://www.ruby-forum.com/attachment/7606/qaruby_fitanalyzer_mockup.png -- Posted via http://www.ruby-forum.com/. -- 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 https://groups.google.com/groups/opt_out.
Андрей Большов
2012-Jul-18 08:26 UTC
Re: executing ruby script from view (no route matches)
First http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to *link_to *uses *controller*, *action *as url options. Second you should add to your routes.rb file correct route for your action (e.g. match "/some_pritty_path" => "fit_anlayzer_controller#execute_analyzer", as: :execute_analyzer) вторник, 17 июля 2012 г., 21:28:20 UTC+4 пользователь Ruby-Forum.com User написал:> > I am new to ruby on rails and trying to build an internal site to manage > several ruby scripts. What I am trying to accomplish; create web page > where an user clicks on a link (Execute Analyzer) to execute ruby script > (runs in the background - FitAnalyzer.rb). I am having trouble > understanding how to route this without redirecting to another web page. > Basically need help how to add the correct format to routes.rb. > > analyzer.html.erb > > <%= link_to "Execute Analyzer", :controller => > ''fit_anlayzer_controller'', :method => ''execute_analyzer'', :popup => true > %> > > fit_analyzer_controller.rb > > class FitAnalyzerController < ApplicationController > def analyzer > end > > def execute_analyzer > # Delayed::Job.enqueue(AnalyzerJob.new(params[:id]), 3) > # command = ''ruby ~/ruby_scripts/fit_analyzer/FitAnalyzer.rb'' > @execute_command = system ''ruby > /Users/gsypolt/rubyqa_project/ruby_scripts/fit_analyzer/FitAnalyzer.rb'' > flash[:notice] = "Executing FitNesse Analyzer" > end > end > > > When accessing http://localhost:3000/fit_analyzer/analyzer receiving > this message below > > No route matches {:controller=>"fit_anlayzer_controller", > :method=>"execute_analyzer", :popup=>true} > > I have been learning ruby on rails from lyndia.com and book (rails 3 > way). > > Attachments: > http://www.ruby-forum.com/attachment/7606/qaruby_fitanalyzer_mockup.png > > > -- > Posted via http://www.ruby-forum.com/. >-- 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. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/4hPJXF4lLdUJ. For more options, visit https://groups.google.com/groups/opt_out.