more of the exception text, to show where the problem occurred
Loading development environment (Rails 3.2.1)
jruby-1.6.5.1 :001 > f = Fire.find_by_sql(“SELECT * FROM fires WHERE
incident_id = ?”, “CA-KNF-5659”)
NoMethodError: undefined method shift' for "CA-KNF-5659":String from /home/jim/.rvm/gems/jruby-1.6.5.1/gems/activerecord-jdbc-adapter-1.2.2/lib/arjdbc/jdbc/adapter.rb:202:insubstitute_binds’
from org/jruby/RubyString.java:2764:in gsub' from org/jruby/RubyString.java:2744:ingsub’
from
/home/jim/.rvm/gems/jruby-1.6.5.1/gems/activerecord-jdbc-adapter-1.2.2/lib/arjdbc/jdbc/adapter.rb:202:in substitute_binds' from /home/jim/.rvm/gems/jruby-1.6.5.1/gems/activerecord-jdbc-adapter-1.2.2/lib/arjdbc/jdbc/adapter.rb:207:inexecute’
from
/home/jim/.rvm/gems/jruby-1.6.5.1/gems/activerecord-jdbc-adapter-1.2.2/lib/arjdbc/jdbc/adapter.rb:337:in select' from /home/jim/.rvm/gems/jruby-1.6.5.1/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:16:inselect_all’
from
/home/jim/.rvm/gems/jruby-1.6.5.1/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in select_all' from /home/jim/.rvm/gems/jruby-1.6.5.1/gems/activerecord-3.2.1/lib/active_record/querying.rb:38:infind_by_sql’
from
/home/jim/.rvm/gems/jruby-1.6.5.1/gems/activerecord-3.2.1/lib/active_record/explain.rb:33:in logging_query_plan' from /home/jim/.rvm/gems/jruby-1.6.5.1/gems/activerecord-3.2.1/lib/active_record/querying.rb:37:infind_by_sql’
from (irb):1:in evaluate' from org/jruby/RubyKernel.java:1088:ineval’
from /home/jim/.rvm/rubies/jruby-1.6.5.1/lib/ruby/1.8/irb.rb:158:in eval_input' from /home/jim/.rvm/rubies/jruby-1.6.5.1/lib/ruby/1.8/irb.rb:271:insignal_status’
from /home/jim/.rvm/rubies/jruby-1.6.5.1/lib/ruby/1.8/irb.rb:155:in eval_input' from org/jruby/RubyKernel.java:1420:inloop’
from org/jruby/RubyKernel.java:1192:in catch' from /home/jim/.rvm/rubies/jruby-1.6.5.1/lib/ruby/1.8/irb.rb:154:ineval_input’
from /home/jim/.rvm/rubies/jruby-1.6.5.1/lib/ruby/1.8/irb.rb:71:in start' from org/jruby/RubyKernel.java:1192:incatch’
from /home/jim/.rvm/rubies/jruby-1.6.5.1/lib/ruby/1.8/irb.rb:70:in start' from /home/jim/.rvm/gems/jruby-1.6.5.1/gems/railties-3.2.1/lib/rails/commands/console.rb:47:instart’
from
/home/jim/.rvm/gems/jruby-1.6.5.1/gems/railties-3.2.1/lib/rails/commands/console.rb:8:in start' from /home/jim/.rvm/gems/jruby-1.6.5.1/gems/railties-3.2.1/lib/rails/commands.rb:41:in(root)’
from org/jruby/RubyKernel.java:1038:in `require’
Rails version
Rails 3.2.1
does this happen with other sql statements that use parameter
substitution ("?")
Yes.
does this happen with other sql statements that don’t use parameter
substitution ("?")
No, those work just fine.
if it’s possible to run this in MRI Ruby, does the problem still occur
in MRI Ruby?
Unfortunately, not at the moment. This app is Torquebox enabled so a few
things would have to be changed, the bundle reloaded, mysql gem
compiled, etc. I use JRuby for everything and rarely, if ever RVM into
MRI.
The long and the short of it is, the method substitute_binds appears to
expect an array. I’m passing a string. Obviously the shift method
doesn’t exist for a string. This is in adapter.rb.
The API link doesn’t include a version, so maybe there was something
about it there back in July 2011 when he wrote it. It may have been
true in a previous version, or an error even then, or an error on his
part.
Sorry I couldn’t be more helpful.
By the way, you’re not doing anything special with that SQL. Can you
use the regular Rails-ish style, find_by_user_industry, instead, or was
that just a simplified example?