# Problem of Active Resource in production mode

**URL:** <https://www.ruby-forum.com/t/problem-of-active-resource-in-production-mode/152031>\
**Category:** Rails\
**Created:** [October 29, 2008, 10:24am UTC](https://www.ruby-forum.com/t/problem-of-active-resource-in-production-mode/152031 "2008-10-29T10:24:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Omnibus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/3ab097/32.png) [@Omnibus](https://www.ruby-forum.com/u/Omnibus)\
**Post date:** [October 29, 2008, 10:24am UTC](https://www.ruby-forum.com/t/problem-of-active-resource-in-production-mode/152031/1 "2008-10-29T10:24:41Z")

</div>

I have the following code in a controller with an AcitveResource base  
class in Farm and Server which working perfectly in development mode  
but not in production. It seems some caching mechanism make it broken  
and I need some help to solve it.

Firstly, the controller passes {“farm\_id”=\>“473170433”} to params.

In order to allow Server changes its site according to the farm\_id,  
then in controller, I add:

Server.site += “/farms/#{params[:farm\_id]}”

Then get the farm item  
@farm = Farm.find(params[:farm\_id])

Now inspecting @farm.id, it is 473170433.

@server = Server.create(:farm\_id =\> @farm.id)

Inspecting @server

#\<Server:0xb70891a4  
@attributes={  
“updated\_at”=\>Wed Oct 29 02:46:18 UTC 2008,  
“farm\_id”=\>473170434,  
^^^^^^^^^^^^^^^^^^^^^^^^^^  
“id”=\>996332954,  
“created\_at”=\>Wed Oct 29 02:46:18 UTC 2008},  
@prefix\_options={}\>

Notice it the farm\_id is 473170434, not the one (473170433) assigned  
in the create call. 473170434 is the farm\_id parameter in the first  
create call after server restart. The code breaks in production  
mode. How can I fix it so that Server can read the farm\_id correctly?

Any help is appreciated.

Thanks

---

<div class="post-metadata">

**Author:** ![Omnibus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/3ab097/32.png) [@Omnibus](https://www.ruby-forum.com/u/Omnibus)\
**Post date:** [October 29, 2008, 10:27am UTC](https://www.ruby-forum.com/t/problem-of-active-resource-in-production-mode/152031/2 "2008-10-29T10:27:02Z")

</div>

On Oct 29, 3:24 am, Omnibus [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I have the following code in a controller with an AcitveResource base  
> class in Farm and Server which working perfectly in development mode  
> but not in production. It seems some caching mechanism make it broken  
> and I need some help to solve it.

It’s slightly hard to say without seeing the exact code, but it’s  
important to know that in production mode code is never reloaded,  
whereas in development mode it is reloaded between requests.

Fred
