Search code examples
ruby-on-railscachingsweeper

rails - caches_action expire_action


I want to expire a cached action and wondered how to generate the correct reference.

#controller
caches_action :index, :layout => false
#generates this fragment which works fine
views/0.0.0.0:3000/article/someid/posts

#sweeper
...
expire_action article_posts_path(:article_id => post.article)
# results in this
Expired fragment: views//en/article/someid/posts (0.0ms)

So this is almost ok, except the host is missing. What do I do that supplies this to the expire_action method?

Thanks in advance.


Solution

  • Use article_posts_url(:article_id => post.article)

    resource_name_url routes generate url with the host set.