# How can I use a 'expire\_fragment' in ActiveRecord

**URL:** <https://www.ruby-forum.com/t/how-can-i-use-a-expire-fragment-in-activerecord/112102>\
**Category:** Rails\
**Created:** [August 15, 2007, 1:40pm UTC](https://www.ruby-forum.com/t/how-can-i-use-a-expire-fragment-in-activerecord/112102 "2007-08-15T13:40:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaoxt1983](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b4bc9f/32.png) [@gaoxt1983](https://www.ruby-forum.com/u/gaoxt1983)\
**Post date:** [August 15, 2007, 1:40pm UTC](https://www.ruby-forum.com/t/how-can-i-use-a-expire-fragment-in-activerecord/112102/1 "2007-08-15T13:40:17Z")

</div>

I must use a ‘expire\_fragment’ in ActiveRecord, I just new an  
ActionController, and use the expire\_fragment, but it doesn’t work if  
I use a style like  
expire\_fragment(:controller=\>‘product’,:action=\>“xxx”,…)

this is the error :

/home/zhixin/lib/ruby-1.8.6/lib/ruby/gems/1.8/gems/actionpack-1.13.3/  
lib/action\_controller/base.rb:522:in `url_for' /home/zhixin/lib/ruby-1.8.6/lib/ruby/gems/1.8/gems/actionpack-1.13.3/ lib/action_controller/caching.rb:326:in`fragment\_cache\_key’  
/home/zhixin/lib/ruby-1.8.6/lib/ruby/gems/1.8/gems/actionpack-1.13.3/  
lib/action\_controller/caching.rb:375:in `expire_fragment' lib/cache.rb:19:in`expire\_product’  
app/models/agency.rb:43:in `after_save' app/models/agency.rb:41:in`each’  
app/models/agency.rb:41:in `after_save' app/controllers/user_controller.rb:182:in`update\_profile’

this is the code:

```
  a = ActionController::Base.new

```

a.expire\_fragment(:controller=\>‘product’,:action=\>‘full\_product\_detail’,:id=\>id,:to=\>‘false’)
