# Undefined Method '|'

**URL:** <https://www.ruby-forum.com/t/undefined-method/167608>\
**Category:** Rails\
**Created:** [May 10, 2009, 5:57am UTC](https://www.ruby-forum.com/t/undefined-method/167608 "2009-05-10T05:57:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![brian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/97f17d/32.png) [@brian](https://www.ruby-forum.com/u/brian)\
**Post date:** [May 10, 2009, 5:57am UTC](https://www.ruby-forum.com/t/undefined-method/167608/1 "2009-05-10T05:57:59Z")

</div>

I generated scaffolding for User with the following schema:

create\_table “users”, :force =\> true do |t|  
t.string “name”  
t.string “company”  
t.string “lastcompany”  
t.datetime “changed”  
t.datetime “created\_at”  
t.datetime “updated\_at”  
end

When I run the automatically generated functional tests against the  
Users controller, I get one failure:

test\_should\_update\_user(UsersControllerTest):  
NoMethodError: undefined method `|’ for Wed Apr 29 23:49:18 UTC  
2009:Time

Oddly, if I just run this one test it passes:

> ruby functional\users\_controller\_test.rb -n test\_should\_update\_user  
> Loaded suite functional/users\_controller\_test  
> Started  
> .  
> Finished in 0.594 seconds.

1 tests, 1 assertions, 0 failures, 0 errors

The failure seems to be on this line of my controller:

```
  if @user.update_attributes(params[:user])

```

Because if I change it to “if true” my test passes.

The only thing unique about this particular class is that it has an  
additional datetime member. I’m not having luck with google searches  
because of that pipe character. Hopefully I’m running into a fairly  
common failure here?

---

<div class="post-metadata">

**Author:** ![brian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/97f17d/32.png) [@brian](https://www.ruby-forum.com/u/brian)\
**Post date:** [May 10, 2009, 7:40am UTC](https://www.ruby-forum.com/t/undefined-method/167608/2 "2009-05-10T07:40:29Z")

</div>

Brian wrote:

That error is saying that at some point in your code there is a  
statement that evaluates to this:

(Wed Apr 29 23:49:18 UTC 2009:Time) |

---

<div class="post-metadata">

**Author:** ![brian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/97f17d/32.png) [@brian](https://www.ruby-forum.com/u/brian)\
**Post date:** [May 10, 2009, 7:11pm UTC](https://www.ruby-forum.com/t/undefined-method/167608/3 "2009-05-10T19:11:09Z")

</div>

On May 10, 4:56 am, Brian [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I generated scaffolding for User with the following schema:
> 
> create\_table “users”, :force =\> true do |t|  
> t.string “name”  
> t.string “company”  
> t.string “lastcompany”  
> t.datetime “changed”

your changed column is squashing an activerecord method called  
changed, rails calls the changed method expecting to get it’s changed  
method, but gets the accessor for your column instead.

Fred

---

<div class="post-metadata">

**Author:** ![brian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/97f17d/32.png) [@brian](https://www.ruby-forum.com/u/brian)\
**Post date:** [May 12, 2009, 6:12am UTC](https://www.ruby-forum.com/t/undefined-method/167608/4 "2009-05-12T06:12:54Z")

</div>

That was it. It took me a while to confirm because I (stupidly) wrote  
a migration to replace “change” (notice the missing “d”) with  
“lastchanged”. The good part is that it forced me to install ruby-  
debug to take a closer look, and I was able to see the problem for  
myself. Thanks for the help!

On May 10, 1:10 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
