Forum: Ruby on Rails Stupid newbie question

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.
9a5c497293dffb91cacef202bad5b602?d=identicon&s=25 jasonlee9 (Guest)
on 2005-11-23 03:18
(Received via mailing list)
Sorry guys but I have to ask this as I'm completely stumped.

I have a table like so

party_type
+-------+
| id    |
| type  |
| _name |
+-------+

And my relevant unit test portion (setup works fine):

def test_truth
  assert_equal 1,        @part_type.id      # works fine
  assert_equal "Person", @party_type._name  # works as well
  assert_equal "Person", @party_type.type   # bombs
end

I get the following messages:
-----------------------------

F
Finished in 0.279416 seconds.

   1) Failure:
test_truth(PartyTypeTest) [test/unit/party_type_test.rb:20]:
<"Person"> expected but was
<PartyType>.

1 tests, 2 assertions, 1 failures, 0 errors

-----------------------------

For the life of me, I can't get 'type' to be recognized. I've tried
an alias, defining another method to return the 'type' attribute/col;
all to no avail. Anyone have any suggestions for this? Tia.

thanks,

- jason
Acd864a79c581fd5f7203ec993896c10?d=identicon&s=25 Deepak Surti <dmsurti@gmail.com> <dmsurti@gmail.co (Guest)
on 2005-11-23 03:24
Your fixture may be reading like this:

party_type:
  id:1
  _name:Person
  type:PartyType

What is your table party_defn (details) and class ?
24d2f8804e6bb4b7ea6bd11e0a586470?d=identicon&s=25 jeremy (Guest)
on 2005-11-23 03:26
(Received via mailing list)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On Nov 22, 2005, at 6:16 PM, Jason Lee wrote:

>
>
> -----------------------------
>
> For the life of me, I can't get 'type' to be recognized. I've tried
> an alias, defining another method to return the 'type' attribute/
> col; all to no avail. Anyone have any suggestions for this? Tia.

The type column is used for single-table inheritance.

Are you using it for this?

If not, I recommend you change the name of your column (perhaps
"kind") or set self.inheritance_column = 'ruby_type' in your Person
class.

jeremy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (Darwin)

iD8DBQFDg9LUAQHALep9HFYRAiNYAKDC+Jg1LBTrtSWfs1mayoeMoJSEQwCgrb1d
2V54DSgT4SZX6Qj/sOmYTgM=
=hCX/
-----END PGP SIGNATURE-----
9a5c497293dffb91cacef202bad5b602?d=identicon&s=25 jasonlee9 (Guest)
on 2005-11-23 03:34
(Received via mailing list)
Ah, self.inheritance_column seemed to do the trick.

Thanks!
This topic is locked and can not be replied to.