当试图运行Rails服务器时,它会在Rake上崩溃

时间:2012-11-07 20:19:00

标签: ruby-on-rails ruby plugins rake

我刚刚将应用程序rails版本从3.0.9升级到3.1.2&也从红宝石1.8.7切换到1.9.2。

尝试在更新后运行服务器时,我收到以下错误消息:

rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/dsl_definition.rb:65:in `directory': wrong number of arguments (0 for 1) (ArgumentError)
    from /Users/Big_Bird/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/dsl_definition.rb:165:in `directory'
    from /Users/Big_Bird/apps/Example/vendor/plugins/calendar_date_select/init.rb:12:in `block (2 levels) in <class:Plugin>'
    from /Users/Big_Bird/apps/Example/vendor/plugins/calendar_date_select/init.rb:11:in `each'
    from /Users/Big_Bird/apps/Example/vendor/plugins/calendar_date_select/init.rb:11:in `block in <class:Plugin>'

现在插件发生错误的代码段为:

%w[calendar_date_select includes_helper].each { |file| 
  require File.join( File.dirname(__FILE__), "lib",file) 
}

ActionView::Helpers::FormHelper.send(:include, CalendarDateSelect::FormHelper)
ActionView::Base.send(:include, CalendarDateSelect::FormHelper)
ActionView::Base.send(:include, CalendarDateSelect::IncludesHelper)

# install files
unless File.exists?(Rails.root + '/public/javascripts/calendar_date_select/calendar_date_select.js')
  ['/public', '/public/javascripts/calendar_date_select', '/public/stylesheets/calendar_date_select', '/public/images/calendar_date_select', '/public/javascripts/calendar_date_select/locale'].each do |dir|
    source = File.join(directory,dir)
    dest = Rails.root + dir
    FileUtils.mkdir_p(dest)
    FileUtils.cp(Dir.glob(source+'/*.*'), dest)
  end
end

我不太确定问题所在,因为插件中列出的所有目录都是正确的,而升级时我不得不从使用RAILS_ROOT切换到Rails.root,但就此而言。

我很感激有关如何解决此问题的任何指导。

1 个答案:

答案 0 :(得分:1)

看起来问题在于这一行:

source = File.join(directory,dir)

您期望directory成为字符串路径吗?如果是这样,我认为它没有在任何地方定义。