JRuby 1.6.3 和 Rails 3.1rc5 和 activerecord-3.1.0.rc5 和 destroy_all

发布于 2024-11-26 22:35:42 字数 1837 浏览 1 评论 0原文

我能够创建能够从 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> 

一切都很好,但是当我运行时

角色.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 之间似乎一切都不正确。

有人对此有帮助吗?

I am able to create able to run my migrations from JRuby 1.6.3 and Rails 3.1rc5 and in a console session create a simple Role object like this:

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> 

All is good but when I run

Role.destroy_all

I get the following stack trace:

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)'

It would seem all is not right between activerecord-3.1.0.rc5 and jruby.

Anybody any help on this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

辞取 2024-12-03 22:35:43

activerecord-jdbc-adapter 方面已经取得了一些进展,您现在可以使用 activerecord-jdbc-adapter 的 master 分支来让您的设置正常工作。只需将以下内容添加到您的 Gemfile 中:

gem 'activerecord-jdbc-adapter', :git => 'https://github.com/nicksieger/activerecord-jdbc-adapter.git

如果您等不及最终的 activerecord-jdbc-adapter gem 并且肯定不在生产中,我只建议您这样做。

There has been some progress on the activerecord-jdbc-adapter front and you can now get your setup working now by using the master branch of activerecord-jdbc-adapter. Just add the following to your Gemfile:

gem 'activerecord-jdbc-adapter', :git => 'https://github.com/nicksieger/activerecord-jdbc-adapter.git

I'd only recommend doing this if you cannot wait for the final activerecord-jdbc-adapter gem and certainly not in production.

撕心裂肺的伤痛 2024-12-03 22:35:43

你是对的。 activerecord-jdbc-adapter 和 Rails 3.1 还不太对劲。我正在努力,希望能在 Rails 3.1 最终版本之前准备好。

You are correct. All is not right yet with activerecord-jdbc-adapter and Rails 3.1. I'm working on it and hope to have it ready by the time Rails 3.1 goes final.

流年已逝 2024-12-03 22:35:43

难道你不需要为它destroy_all指定条件吗?

例如

http://apidock.com/rails/ActiveRecord/Base/destroy_all/class

Don't you have to specify conditions for it destroy_all?

e.g.

http://apidock.com/rails/ActiveRecord/Base/destroy_all/class

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文