Forum: Ruby on Rails update_attributes unsets my object

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.
059ed46172a087063ce26250e44c8627?d=identicon&s=25 Fernando Perez (fernando)
on 2008-11-20 18:26
I just run in a very strange behavior.

In one of my actions, I trigger: @object.update_attributes(:attr1 =>
...)

Now in the corresponding view, @object is nil. Is that a normal behavior
from Rails? Why would it unset the object?
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-11-20 18:49
(Received via mailing list)
On 20 Nov 2008, at 17:26, Fernando Perez wrote:

>
> I just run in a very strange behavior.
>
> In one of my actions, I trigger: @object.update_attributes(:attr1 =>
> ...)
>
> Now in the corresponding view, @object is nil. Is that a normal
> behavior
> from Rails? Why would it unset the object?

I doubt that is the whole story. Post more information

Ffred
059ed46172a087063ce26250e44c8627?d=identicon&s=25 Fernando Perez (fernando)
on 2008-11-20 21:24
Frederick Cheung wrote:
> On 20 Nov 2008, at 17:26, Fernando Perez wrote:
>
>>
>> I just run in a very strange behavior.
>>
>> In one of my actions, I trigger: @object.update_attributes(:attr1 =>
>> ...)
>>
>> Now in the corresponding view, @object is nil. Is that a normal
>> behavior
>> from Rails? Why would it unset the object?
>
> I doubt that is the whole story. Post more information
>
> Ffred

Thank your Frederick for your prompt answer. You were perfectly right, I
hadn't seen that I was doing something so stupid as:

@object.update_attributes(:attr1 => @object.attr1)

That kind of recursion is definitely forbidden. I don't know how such a
silly idea came to my mind.
This topic is locked and can not be replied to.