0

我正在执行 Thor 任务,我想将 gem 添加到我的 gem 文件中的资产组(见下文)。

gem_group 命令(从标准 Rails 应用程序模板中得知)在 Thor 任务中似乎不起作用(请参阅底部的错误)。

我怎样才能最好地从 Thor 任务中将 gem 添加到 gem 文件中的组中?

欢迎任何想法 - 谢谢。

class ThorBuild < Thor

  desc "add_gems", "Adds the gems I need"
  def add_gems
    puts "Running add_gems"

    gem 'mongoid', '~> 3.0.15'
    gem 'bson_ext'
    gem 'less-rails'
    gem 'devise'

    gem_group :assets do
      gem 'therubyracer', '= 0.10.0', :platforms => :ruby
      gem 'twitter-bootstrap-rails'
    end
  end

end

输出看起来像这样......

Running add_gems
/home/ubuntu/sites/ThorBuild.thor:12:in `add_gems': undefined method `gem_group' for #<Thor::Sandbox::ThorBuild:0x000000007b5110> (NoMethodError)
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/lib/thor/task.rb:27:in `run'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/lib/thor/invocation.rb:120:in `invoke_task'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/lib/thor.rb:275:in `dispatch'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/lib/thor/base.rb:425:in `start'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/lib/thor/runner.rb:36:in `method_missing'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/lib/thor/task.rb:29:in `run'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/lib/thor/task.rb:126:in `run'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/lib/thor/invocation.rb:120:in `invoke_task'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/lib/thor.rb:275:in `dispatch'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/lib/thor/base.rb:425:in `start'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/gems/thor-0.16.0/bin/thor:6:in `<top (required)>'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/bin/thor:19:in `load'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/bin/thor:19:in `<main>'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `eval'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `<main>'
4

0 回答 0