rails/rails — Issue #3313: MissingAttributeError for database column in after_find callback
Author: shlevy
Created: 2011-10-12 21:02:25+00:00
State: open

Under some circumstances (which are not clear to me), calling self.column_name in an after_find throws a MissingAttributeError even when column_name is a valid db column. In particular, I have a project with a milestones table that has a billing_invoice field where

Milestone.find 1, include: [project: [:time_logs]], order: "projects.name"

fails with a MissingAttributeError for billing_invoice within the after_find callback but

Milestone.all conditions: "milestones.id = 1", include: [project: [:time_logs]], order: "projects.name"

succeeds. An essentialized version of the project with steps to repro the bug can be found at https://github.com/shlevy/after-find-bug