# "Undefined method merge" when using sweeper

**URL:** <https://www.ruby-forum.com/t/undefined-method-merge-when-using-sweeper/133580>\
**Category:** Rails\
**Created:** [April 1, 2008, 9:35pm UTC](https://www.ruby-forum.com/t/undefined-method-merge-when-using-sweeper/133580 "2008-04-01T21:35:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [April 1, 2008, 9:35pm UTC](https://www.ruby-forum.com/t/undefined-method-merge-when-using-sweeper/133580/1 "2008-04-01T21:35:16Z")

</div>

Hi,

I’m trying to use sweepers for the first time and got a problem - I  
get “undefined method `merge’ for “/signature/  
f2d7c7c66450b169.html”:String”. The “/signature/f2d7c7c66450b169.html”  
part of the error message is the cached page.

Here’s my sweeper:  
class FooSweeper \< ActionController::Caching::Sweeper  
observe Foo

def after\_save(foo)  
expire\_cache(foo)  
end

def after\_destroy(foo)  
expire\_cache(foo)  
end

def expire\_cache(foo)  
expire\_page signature\_path(:opaque\_id =\> foo.opaque\_id) # line 13  
expire\_page signature\_image\_path(:opaque\_id =\> foo.opaque\_id)  
end

end

The signature\_path(:opaque\_id =\> string) generates “/signature/  
string.html” route, so this part works correctly.

Here’s stack trace:  
…/vendor/rails/actionpack/lib/action\_controller/caching.rb:125:in  
`expire_page' .../vendor/rails/actionpack/lib/action_controller/caching.rb:612:in`send’  
…/vendor/rails/actionpack/lib/action\_controller/caching.rb:612:in  
`method_missing' #{RAILS_ROOT}/app/sweepers/foo_sweeper.rb:13:in`expire\_cache’  
#{RAILS\_ROOT}/app/sweepers/foo\_sweeper.rb:5:in `after_save' .../app/controllers/foo_controller.rb:61:in`unsubscribe’

Any ideas what can be wrong? I’m using Rails 1.2.6.  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [April 1, 2008, 9:50pm UTC](https://www.ruby-forum.com/t/undefined-method-merge-when-using-sweeper/133580/2 "2008-04-01T21:50:02Z")

</div>

On Apr 1, 9:34 pm, szimek [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> expire_page signature_image_path(:opaque_id => foo.opaque_id)
> 
> ```
> 
> …/vendor/rails/actionpack/lib/action\_controller/caching.rb:612:in  
> `send' .../vendor/rails/actionpack/lib/action_controller/caching.rb:612:in `method\_missing’  
> #{RAILS\_ROOT}/app/sweepers/foo\_sweeper.rb:13:in `expire_cache' #{RAILS_ROOT}/app/sweepers/foo_sweeper.rb:5:in `after\_save’  
> …/app/controllers/foo\_controller.rb:61:in `unsubscribe’
> 
> Any ideas what can be wrong? I’m using Rails 1.2.6.  
> Thanks in advance

Solved it myself - just changed expire\_page to  
ApplicationController.expire\_page. I’m not sure why it didn’t work  
before - I was using Railscast 89 - “Page caching” as the reference.
