Forum: Ruby on Rails Problem of Active Resource in production mode

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Omnibus (Guest)
on 2008-10-29 11:24
(Received via mailing list)
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
Frederick C. (Guest)
on 2008-10-29 11:27
(Received via mailing list)
On Oct 29, 3:24 am, Omnibus <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
This topic is locked and can not be replied to.