Ruby Forum Ruby on Rails > Example using uncached

Posted by mh (Guest)
on 14.03.2008 23:29
(Received via mailing list)
I am inserting rows into a MS SQL Server table from a Rails 2.0
application.  However, when ActiveRecord issues a "SELECT @@IDENTITY
AS Ident" after each insert, it only ever returns the values of the
initial SELECT.  (The log shows it's hitting cache.)

Is this the proper way to disable caching for these inserts?

    files.each do |f|
      ActiveRecord::Base.connection.uncached do
        self.items.create!(:file => f) unless f.blank?
      end
    end