# Update\_attribute weirdness in edge

**URL:** <https://www.ruby-forum.com/t/update-attribute-weirdness-in-edge/120842>\
**Category:** Rails\
**Created:** [November 21, 2007, 1:50am UTC](https://www.ruby-forum.com/t/update-attribute-weirdness-in-edge/120842 "2007-11-21T01:50:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dishkuvek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@dishkuvek](https://www.ruby-forum.com/u/dishkuvek)\
**Post date:** [November 21, 2007, 1:50am UTC](https://www.ruby-forum.com/t/update-attribute-weirdness-in-edge/120842/1 "2007-11-21T01:50:53Z")

</div>

If I am changing a boolean value, no matter what approach I take, I  
get the same results:

lets say table “users” has an “enabled” field that is boolean:

user = User.find(1)  
user.enabled.toggle  
NoMethodError: undefined method `toggle’ for false:FalseClass

user = User.find(1)  
toggle(user.enabled)  
NoMethodError: undefined method `toggle’ for #Object:0x389a0

user = User.find(1)  
user.enabled = true  
user.save  
ArgumentError: wrong number of arguments (2 for 1)

user = User.find(1)  
user.update\_attribute(:enabled, true)  
ArgumentError: wrong number of arguments (2 for 1)

hmm, that’s weird, I thought update\_attribute took two arguments,  
well, maybe I should try 1 argument anyhow…

user = User.find(1)  
user.update\_attribute(:enabled =\> true)  
ArgumentError: wrong number of arguments (1 for 2)

!!! Smacks head !!!

Anyone else experiencing similar behavior?

---

<div class="post-metadata">

**Author:** ![dishkuvek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@dishkuvek](https://www.ruby-forum.com/u/dishkuvek)\
**Post date:** [November 21, 2007, 2:10am UTC](https://www.ruby-forum.com/t/update-attribute-weirdness-in-edge/120842/2 "2007-11-21T02:10:46Z")

</div>

On 21 Nov 2007, at 00:50, Dick D. wrote:

> If I am changing a boolean value, no matter what approach I take, I  
> get the same results:
> 
> user = User.find(1)  
> user.enabled = true  
> user.save  
> ArgumentError: wrong number of arguments (2 for 1)

> !!! Smacks head !!!
> 
> Anyone else experiencing similar behavior?

Nope, never seen that. Have you done anything interesting (ie  
overriding bits of activerecord), either via a plugin or directly in  
the User model ? I’m guessing the stack trace for the ArgumentErrors  
that get thrown might be interesting.

Fred

---

<div class="post-metadata">

**Author:** ![dishkuvek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@dishkuvek](https://www.ruby-forum.com/u/dishkuvek)\
**Post date:** [November 21, 2007, 5:38am UTC](https://www.ruby-forum.com/t/update-attribute-weirdness-in-edge/120842/3 "2007-11-21T05:38:51Z")

</div>

Thank you! I hadn’t thought of the plugins messing things up, so I  
started doing some testing. I checked-out a copy on my fedora VPS (my  
main dev box is a mac) and the same thing was happening, with a fresh  
freeze of the rails trunk too. So I started deleting the plugins one  
by one, and it turned out that it was betternestedset.

Thanks for the help though, if you had not mentioned the plugins, I  
would have spent even more time on this already huge time waster! I’m  
going to try and figure out what is happening in betternestedset  
though.

On Nov 20, 8:09 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![dishkuvek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ebca7d/32.png) [@dishkuvek](https://www.ruby-forum.com/u/dishkuvek)\
**Post date:** [November 21, 2007, 10:29pm UTC](https://www.ruby-forum.com/t/update-attribute-weirdness-in-edge/120842/4 "2007-11-21T22:29:05Z")

</div>

@foo.update\_attributes =\>

> **[ActiveRecord::Base](https://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001056)**
>
> Active Record Active Record objects don't specify their attributes directly, but rather infer them from the table definition with which they're linked.

@foo.toggle =\>

> **[ActiveRecord::Base](https://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001063)**
>
> Active Record Active Record objects don't specify their attributes directly, but rather infer them from the table definition with which they're linked.

hope that helps.
