我能够创建能够从JRuby 1.6.3和Rails 3.1rc5运行我的迁移,并在控制台会话中创建一个简单的Role对象,如下所示:
jruby-1.6.3 :001 > role = Role.new(:name => "Admin")
(1.0ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
=> #<Role id: nil, name: "Admin", created_at: nil, updated_at: nil>
一切都很好但我跑的时候
Role.destroy_all
我得到以下堆栈跟踪:
jruby-1.6.3 :003 > Role.destroy_all
ArgumentError: wrong number of arguments (3 for 2)
from /Users/paulcowan/.rvm/gems/jruby-1.6.3/gems/activerecord-3.1.0.rc5/lib/active_record/base.rb:470:in `find_by_sql'
from /Users/paulcowan/.rvm/gems/jruby-1.6.3/gems/activerecord-3.1.0.rc5/lib/active_record/relation.rb:111:in `to_a'
from /Users/paulcowan/.rvm/gems/jruby-1.6.3/gems/activerecord-3.1.0.rc5/lib/active_record/relation.rb:289:in `destroy_all'
from org/jruby/RubyBasicObject.java:1684:in `__send__'
from /Users/paulcowan/.rvm/gems/jruby-1.6.3/gems/activerecord-3.1.0.rc5/lib/active_record/base.rb:438:in `destroy_all'
from (irb):3:in `evaluate'
from org/jruby/RubyKernel.java:1093:in `eval'
from org/jruby/RubyKernel.java:1419:in `loop'
from org/jruby/RubyKernel.java:1205:in `catch'
from org/jruby/RubyKernel.java:1205:in `catch'
from /Users/paulcowan/.rvm/gems/jruby-1.6.3/gems/railties-3.1.0.rc5/lib/rails/commands/console.rb:45:in `start'
from /Users/paulcowan/.rvm/gems/jruby-1.6.3/gems/railties-3.1.0.rc5/lib/rails/commands/console.rb:8:in `start'
from /Users/paulcowan/.rvm/gems/jruby-1.6.3/gems/railties-3.1.0.rc5/lib/rails/commands.rb:40:in `(root)'
from org/jruby/RubyKernel.java:1047:in `require'
from script/rails:6:in `(root)'
在activerecord-3.1.0.rc5和jruby之间似乎一切都不对。
有人对此有任何帮助吗?
答案 0 :(得分:2)
activerecord-jdbc-adapter前端已取得一些进展,您现在可以使用activerecord-jdbc-adapter的主分支使您的设置正常工作。只需将以下内容添加到您的Gemfile:
gem'activerecord-jdbc-adapter',:git =&gt; “https://github.com/nicksieger/activerecord-jdbc-adapter.git
如果您不能等到最终的activerecord-jdbc-adapter gem并且肯定没有投入生产,我建议您这样做。
答案 1 :(得分:1)
你是对的。使用activerecord-jdbc-adapter和Rails 3.1,一切都还不对。我正在研究它并希望在Rails 3.1最终确定之前做好准备。
答案 2 :(得分:0)