0

我正在开发 2.0.2 rails 应用程序。现在,当我从 Windows pc 执行命令时,rake db:migate它会给出Errno::ENOEXEC in SystemsController#index.

有没有其他方法可以从 windows pc 上的 rails 应用程序执行系统命令?

这是错误:

Errno::ENOEXEC in SystemsController#index

Exec format error - rake db:migrate

RAILS_ROOT: E:/RoR/ibt/InstantRails-2.0-win/rails_apps/config
Application Trace | Framework Trace | Full Trace

E:/RoR/ibt/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``' ``
E:/RoR/ibt/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``'`
app/controllers/systems_controller.rb:24:in `index'

我正在使用 ruby​​ 控制台:

irb(main):001:0> system('dir')
Volume in drive E has no label.
Volume Serial Number is 522C-BDB1

 Directory of E:\RoR\ibt\InstantRails-2.0-win\rails_apps\config

 11/29/2012  03:11 PM    <DIR>          .
 11/29/2012  03:11 PM    <DIR>          ..
 11/29/2012  02:41 PM    <DIR>          app
 11/29/2012  02:42 PM    <DIR>          config

 => true
 irb(main):002:0> system('rake db:migrate')
 => false
 irb(main):003:0>  
4

1 回答 1

0

我通过从 rake 所在的批处理文件中运行 rake 文件解决了这个问题。

irb(main):001:0> system('dir')
Volume in drive E has no label.
Volume Serial Number is 522C-BDB1

Directory of E:\RoR\ibt\InstantRails-2.0-win\rails_apps\config

11/29/2012  03:11 PM    <DIR>          .
11/29/2012  03:11 PM    <DIR>          ..
11/29/2012  02:41 PM    <DIR>          app
11/29/2012  02:42 PM    <DIR>          config

=> true
irb(main):002:0> system('rake db:migrate')
=> false

在控制器文件中

system("#{RAILS_ROOT}/../../ruby/bin/rake.bat db:migrate")

给出结果

 == 99 AddFieldtoSystemAssoziations: migrating =================================
 == 99 AddFieldtoSystemAssoziations: migrated (0.0391s) ========================
于 2012-12-11T09:59:23.807 回答