Forum: Ruby on Rails Undefined Method '|'

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.
Brian (Guest)
on 2009-05-10 07:57
(Received via mailing list)
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?
7stud -. (Guest)
on 2009-05-10 09:40
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) | <something else here>
Frederick C. (Guest)
on 2009-05-10 21:11
(Received via mailing list)
On May 10, 4:56 am, Brian <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
Brian (Guest)
on 2009-05-12 08:12
(Received via mailing list)
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>
This topic is locked and can not be replied to.