# Json.erb views and strange caching

**URL:** <https://www.ruby-forum.com/t/json-erb-views-and-strange-caching/142397>\
**Category:** Rails\
**Created:** [July 7, 2008, 3:34pm UTC](https://www.ruby-forum.com/t/json-erb-views-and-strange-caching/142397 "2008-07-07T15:34:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DEfusion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e68b1a/32.png) [@DEfusion](https://www.ruby-forum.com/u/DEfusion)\
**Post date:** [July 7, 2008, 3:34pm UTC](https://www.ruby-forum.com/t/json-erb-views-and-strange-caching/142397/1 "2008-07-07T15:34:59Z")

</div>

I’m responding in JSON in quite a lot of places within my application  
and as I’m doing quite a bit of work (e.g. defining which  
relationships to return and which fields etc.) within my to\_json()  
calls I decided to move from:

render :json =\> @obj.to\_json( … )

Within my controller and to move them to views, so for example I  
created a show.json.erb which has:

\<%= @obj.to\_json(…) -%\>

This seems to work, however when I change the view (e.g. add or remove  
attributes it will include in the json - within the :only param) when  
the app is running (in development mode) the changes are not applied  
within the response, I have to kick the server to make it update.

Firstly am I correct in my use/formatting of the json.erb view and if  
so does anyone know of a workaround to this issue (I’ve tried both on  
Rails 2.0 & 2.1 and get the same issue on both).
