简体   繁体   中英

Strange Rails 3.1+ error after upgrade: undefined method 'parent_table_name'

undefined method `parent_table_name' for class `ActiveRecord::Associations::JoinDependency::JoinAssociation'

I have recently upgraded our app from Rails 2.3.12 to Rails 3.0.12. I cleared all deprecation warnings and then proceeded to upgrade to Rails 3.1.4. After the upgrade to Rails 3.1.4, I am now getting this error every time the application is loaded and the accessed in the browser. It is also raised when running the tests. The really strange part is that a simple refresh causes the app to continue forward without another error. However, stopping the server and restarting it causes it to fire again during the next access. It doesn't seem to be happening in one place either. Different methods on different models or controllers can be seen in the backtrace when this error fires.

I have tried stepping through the code using the debugger, but it won't fire. I have tried googling for this error and found nothing. I've tried walking through the backtrace looking for anything out of the ordinary and tried updating some older legacy code to see if that helped.

It seems like it has something to do with my associations so I looked for any associations that weren't basic and refactored to make them standard, basic associations. I have several other Rails 3.1 and 3.2 apps and have not seen this error using any of the usual associations I use. I had some habtm associations with extra columns so I converted them into has_many :through by creating a join model. I have some associations with :conditions and :includes on them. That's not something I usually do, but I inherited this app from a previous developer.

Does this error ring a bell with anyone?? Any tips or pointer that could help me trace it would be wonderful.

Ok, I figured this out. It had nothing to do with anything weird in Rails. One of the previous app developers had written a custom delegate method that was overriding Module#delegate. Once I removed that code, everything worked fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM