# Fragment caching file\_store problems

**URL:** <https://www.ruby-forum.com/t/fragment-caching-file-store-problems/170014>\
**Category:** Rails\
**Created:** [June 11, 2009, 10:56am UTC](https://www.ruby-forum.com/t/fragment-caching-file-store-problems/170014 "2009-06-11T10:56:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tachekent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7993a0/32.png) [@tachekent](https://www.ruby-forum.com/u/tachekent)\
**Post date:** [June 11, 2009, 10:56am UTC](https://www.ruby-forum.com/t/fragment-caching-file-store-problems/170014/1 "2009-06-11T10:56:59Z")

</div>

Hello,  
I’m having problems on both my production and development servers with  
fragment caching.

Every time I try to cache something using \<% cache do %\>, I get the  
following error:  
Couldn’t create cache directory: views/0.0.0.0:3000/jobs/106/questions/  
174 (wrong number of arguments (2 for 1))  
but strangely, all of the directories apart from the last one are  
created. Adding path components to generate a key makes no difference.

I have no idea how to debug this, and have googled to no avail. I  
don’t have any caching plugins installed.

environment.rb:  
config.action\_controller.cache\_store = :file\_store, “#{RAILS\_ROOT}/  
cache”  
and I have perform\_caching set to true in both dev and production and  
I set my cache directory to 777, all to no avail.

About your application’s environment  
Ruby version 1.8.7 (i686-darwin9.3.0)  
RubyGems version 1.3.3  
Rails version 2.2.2  
Active Record version 2.2.2  
Action Pack version 2.2.2  
Active Resource version 2.2.2  
Action Mailer version 2.2.2  
Active Support version 2.2.2

Does anyone have any idea what this could be?  
Any advice most gratefully received.  
thanks  
dorian

---

<div class="post-metadata">

**Author:** ![tachekent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7993a0/32.png) [@tachekent](https://www.ruby-forum.com/u/tachekent)\
**Post date:** [June 12, 2009, 12:14pm UTC](https://www.ruby-forum.com/t/fragment-caching-file-store-problems/170014/2 "2009-06-12T12:14:31Z")

</div>

I’ve managed to make this work by changing the following lines in  
active\_support/cache/file\_store.rb

- File.atomic\_write(real\_file\_path(name), cache\_path) { |f| f.write  
(Marshal.dump(value)) }

- File.atomic\_write(real\_file\_path(name), cache\_path) { |f|  
Marshal.dump(value, f) }

as far as I can see, it’s doing the same thing, but for some reason  
Marshal won’t treat f as an IOstream as I think it’s supposed to.  
I don’t really like changing it there though, and I’d like to know why  
it doesn’t work as it’s supposed to.

any thoughts still welcome

d
