我的Rails应用程序中有以下模型:
class Window < Gosu::Window
def initialize
super( 250, 100, false )
@background_image = Gosu::Image.new( self, 'hello.png' )
end
def draw
@background_image.draw( 0, 0, 1 )
end
def button_down(id)
close
end
end
正如您所看到的,该模型基本上是用于启动Gosu库窗口的“hello world”。我的想法是“Ruby Tips #336 – Turn Rails into a Game Engine”。当我执行以下操作时,问题就开始了:
$ rails console
2.2.1 :001> win = Window.new
我按下回车后立即出现以下堆栈跟踪的分段错误:
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/spring-1.4.4/lib/spring/application/boot.rb:18:in `<top (required)>'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/spring-1.4.4/lib/spring/application.rb:125:in `run'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/spring-1.4.4/lib/spring/application.rb:125:in `loop'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/spring-1.4.4/lib/spring/application.rb:131:in `block in run'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/spring-1.4.4/lib/spring/application.rb:156:in `serve'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/spring-1.4.4/lib/spring/application.rb:156:in `fork'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/spring-1.4.4/lib/spring/application.rb:183:in `block in serve'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/spring-1.4.4/lib/spring/command_wrapper.rb:38:in `call'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/spring-1.4.4/lib/spring/commands/rails.rb:6:in `call'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `load'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `block in load'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `load'
/Users/giancarloguerra/Desktop/testgosu/bin/rails:9:in `<top (required)>'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `block in require'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:68:in `console'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/console.rb:9:in `start'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/console.rb:110:in `start'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb.rb:394:in `start'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb.rb:394:in `catch'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb.rb:395:in `block in start'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb.rb:485:in `eval_input'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb/ruby-lex.rb:230:in `each_top_level_statement'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb/ruby-lex.rb:230:in `catch'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb/ruby-lex.rb:231:in `block in each_top_level_statement'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb/ruby-lex.rb:231:in `loop'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb/ruby-lex.rb:245:in `block (2 levels) in each_top_level_statement'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb.rb:486:in `block in eval_input'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb.rb:623:in `signal_status'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb.rb:489:in `block (2 levels) in eval_input'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb/context.rb:379:in `evaluate'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb/workspace.rb:86:in `evaluate'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb/workspace.rb:86:in `eval'
(irb):1:in `irb_binding'
(irb):1:in `new'
/Users/giancarloguerra/Desktop/testgosu/app/models/window.rb:5:in `initialize'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/gosu-0.10.4/lib/gosu/swig_patches.rb:19:in `initialize'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/gosu-0.10.4/lib/gosu/swig_patches.rb:19:in `initialize'
以及有关控制台加载功能的信息。最后,控制台告诉我,我可能发现了一个错误,我应该报告它。
以下是我对此所做的事情:
我在这里完全没有想法。关于可能发生什么的任何建议?我感谢您的帮助。
答案 0 :(得分:0)
事实证明,'Spring'宝石造成了问题。删除后,窗口执行了:)