没有从视图调用参数的辅助方法

时间:2015-10-08 12:19:53

标签: ruby-on-rails ruby progress-bar

我正在Ruby on Rails中实现一个进度条,我需要在脚本执行递增时更新它。我创建了一个伪造的进度条增量。

控制器/ host_controller.rb

require "ruby-progressbar"

module Patchmanagement

  class HostsController < ::HostsController
    helper_method :all
    before_filter :new_action

    def new_action(title, &block)
      import = fork(&block)
      progress = fork do
        #fork Progress bar
        progressbar = ProgressBar.create(title: title, total: nil)
        trap "INT" do
          progressbar.total = 100
          progressbar.finish
          exit
        end
        loop do
          #increment progress bar
          progressbar.increment
          sleep 0.5
        end
      end
      #wait for process to be complete
      Process.wait(import)
      Process.kill(2, progress)
    end
  end
end

调用new_action方法表单视图部分:

查看/动作/ new_action.rb

<p>let it be</p>
<% new_action("progress bar") do
  system "/opt/script.sh"
end %>

抛出"wrong number of arguments (0 for 1)"。当我删除  它引发的helper_method符号new_action method not found

0 个答案:

没有答案