rb:502:in `select'
from
/usr/lib/ruby/gems/1.8/
gems/activerecord-1.15.3/lib/active_record/
connection_adapters/abstract/database_statements.rb:7:in
`select_all'
from /usr/lib/ruby/gems/1.8/
gems/activerecord-1.15.3/lib/active_record/base.rb:427:in
`find_by_sql' from artest.rb:10
PreparedStatementInvalid
This error is raised when you have not provided the correct bind variables for a prepared
statement. Prepared statements are often used as a defense against SQL injection attacks (we
talk about SQL injection attacks in Chapter 2 and again in Chapter 8) as well as for improving
performance with certain compiled languages, such as Java. The most common problem is
forgetting to supply the correct number of values for your prepared statement. In the following
example, our prepared statement expects a username and password to be supplied, but
we only provide a username ("Kevin"), thereby raising a PreparedStatementInvalid error.
CHAPTER 6 ?– ACTIVE RECORD TESTING AND DEBUGGING 150
# program that raises a PreparedStatementInvalid error
require 'rubygems'
reuiqre 'activerecord'
ActiveRecord::Base.
Pages:
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345