Prepare and execute statements with ActiveRecord using PostgreSQL
问题 I am trying to insert values via a prepared statement using ActiveRecord. However, everytime I try: conn = ActiveRecord::Base.connection conn.prepare "SELECT * from sampletable where id = $1" conn.execute 3 After the second statement, I get: NoMethodError: undefined method `prepare' for #<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter:0x000001027442c8> What should I do? I'm running Rails 3.2.1 and Ruby 1.9.2 UPDATE: I solved the problem. Thanks for the response, but it didn't work for