Thanks Rick - I see and understand the options now.
I''ve tried what you said and it doesn''t appear to work, but
it''s probably
some other pilot error - I''ll keep looking.
Is this the ''standard'' way to handle things in your opinion?
Or should I be
coding this a different way?
Talking of docs, the documentation for Rails is really very good. As an
almost total newbie to Ruby and Rails, it''s taken me only a few days to
get
into the groove, and that''s including finding IDE''s and so on.
-----Original Message-----
From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
[mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On
Behalf Of Rick Olson
Sent: 11 April 2005 15:56
To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
Subject: Re: [Rails] Association/Refresh Problem
Rails caches the associations for the current request. If you want to
explicitly tell rails to refresh, try
''task.system(true).description''.
As always, consult the documentation for more info.
http://rails.rubyonrails.com/classes/ActiveRecord/Associations/ClassMethods.
html#M000396
On 4/11/05, Marc Holmes
<marc.holmes-FhtRXb7CoQBt1OO0OYaSVA@public.gmane.org>
wrote:> Hello,
>
> I''m a bit of a rails Newbie, so please go easy.
>
> I have 2 classes:
> TASK (id, description, systemid)
> SYSTEM (id, description)
>
> And have set up the classes with relevant associations:
>
> class Task < ActiveRecord::Base
> has_one :system, :class_name => "System", :foreign_key =>
"id"
> end
>
> class System < ActiveRecord::Base
> belongs_to :task, :foreign_key => "systemid"
> end
>
> When I update the task.systemid using a dropdown and the regular
''update''
> method it works fine:
> - I can see the change in the db
> - When I render the task.systemid it shows correctly.
>
> The problem is that if I ask to render task.system.description, it still
> displays the old system name. So it seems that I need to reload the object
> graph (or whatever). Is this behaviour expected? What am I doing wrong?
> Should I be using a find method with the systemid instead of walking the
> object graph?
>
> Cheers,
>
> Marc
> http://bitarray.co.uk/marc
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
--
rick
http://techno-weenie.net
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails