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

。_饼干妹妹 提交于 2020-01-06 03:03:22

问题


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?


回答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.




回答2:


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.




回答3:


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

e.g.

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



来源:https://stackoverflow.com/questions/6851112/jruby-1-6-3-and-rails-3-1rc5-and-activerecord-3-1-0-rc5-and-destroy-all

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!