# Set\_table\_name strangeness

**URL:** <https://www.ruby-forum.com/t/set-table-name-strangeness/48091>\
**Category:** Rails\
**Created:** [November 16, 2005, 6:05pm UTC](https://www.ruby-forum.com/t/set-table-name-strangeness/48091 "2005-11-16T18:05:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![belorion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@belorion](https://www.ruby-forum.com/u/belorion)\
**Post date:** [November 16, 2005, 6:05pm UTC](https://www.ruby-forum.com/t/set-table-name-strangeness/48091/1 "2005-11-16T18:05:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![belorion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@belorion](https://www.ruby-forum.com/u/belorion)\
**Post date:** [November 16, 2005, 8:43pm UTC](https://www.ruby-forum.com/t/set-table-name-strangeness/48091/2 "2005-11-16T20:43:08Z")

</div>

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!!

---

<div class="post-metadata">

**Author:** ![belorion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@belorion](https://www.ruby-forum.com/u/belorion)\
**Post date:** [November 16, 2005, 9:13pm UTC](https://www.ruby-forum.com/t/set-table-name-strangeness/48091/3 "2005-11-16T21:13:21Z")

</div>

-----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](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-----

---

<div class="post-metadata">

**Author:** ![belorion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@belorion](https://www.ruby-forum.com/u/belorion)\
**Post date:** [November 16, 2005, 9:52pm UTC](https://www.ruby-forum.com/t/set-table-name-strangeness/48091/4 "2005-11-16T21:52:33Z")

</div>

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

Matt
