Set_table_name strangeness


#1

Hello everyone. My code broke recently, and I can’t figure out why
(perhaps
it was the upgrade to 0.14.3?). Anyway, I have an ActiveRecord mapping
to my
phpBB database. Pulling data from that mapping works just fine. However,
when I try to save data (ie on a ‘create’ or ‘save’) I get this error:

undefined local variable or method `table_name’ for
#PhpbbPostsText:0x8e7d0dc

This had been working just fine before, and I hadn’t touched the mapping
in
quite some time (which is why I suspect the Rails upgrade).
Did something change in recent Rails/ActiveRecord upgrades? Why would I
be
able to pull data from the mapping without problem (clearly it
understands
the which table name to use in this case!?) but when I go to save I get
an
error. This happens both when browsing the site (lighttpd/fcgi) as well
as
when running script/console in dev mode.

Any idea what is going on here? My model simply looks like this right
now:

class PhpbbPostsText < ActiveRecord::Base
set_primary_key :posts_text_id
set_table_name :phpbb_posts_text
end


#2

I hate replying to my own post, but I figured out what was going on.

The name of the primary key in the table of interest had changed. Why
this
was throwing a undefined method error for “table_name” instead of a “I
can’t
find this primary key field” error I’m not sure, cause that was very
misleading!!


#3

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Nov 16, 2005, at 9:03 AM, Belorion wrote:

Hello everyone. My code broke recently, and I can’t figure out why
(perhaps it was the upgrade to 0.14.3?). Anyway, I have an
ActiveRecord mapping to my phpBB database. Pulling data from that
mapping works just fine. However, when I try to save data (ie on
a ‘create’ or ‘save’) I get this error:

undefined local variable or method `table_name’ for
#PhpbbPostsText:0x8e7d0dc

This was a bug in 0.14.2 that was fixed in 0.14.3. Are you sure
you’re up-to-date?

If upgrading does not resolve the error, please post a ticket at
http://dev.rubyonrails.org/newticket
including the full backtrace for the error.

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

iD8DBQFDe5KEAQHALep9HFYRAvEvAKCoRg+6HE6syDfyB3p0AavKaZ3xGQCdGGT3
BNJHhrhkGc6uqRLd30AjwYo=
=xNVv
-----END PGP SIGNATURE-----


#4

My mistake. I though TextDrive had gone to 0.14.3, but they are indeed
still
at 0.14.2.

Matt