# Example using uncached

**URL:** <https://www.ruby-forum.com/t/example-using-uncached/131999>\
**Category:** Rails\
**Created:** [March 14, 2008, 11:29pm UTC](https://www.ruby-forum.com/t/example-using-uncached/131999 "2008-03-14T23:29:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 14, 2008, 11:29pm UTC](https://www.ruby-forum.com/t/example-using-uncached/131999/1 "2008-03-14T23:29:55Z")

</div>

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
```
