I'm having trouble with one of my Rails model associations. They seem simple enough, I have 99% of them working. But in one of them, when I try to access a foreign key record, I get:
undefined method `target' for #<Environment:0xb766c70c>
vendor/rails/activerecord/lib/active_record/base.rb:1848:in `method_missing' vendor/rails/activerecord/lib/active_record/associations.rb:891:in `environment' app/models/revision.rb:154:in `start' app/controllers/revisions_controller.rb:9:in `start'
Has anyone seen this? My associations are:
class Revision < ActiveRecord::Base belongs_to :environment belongs_to :source_revision, :class_name => 'Revision', :foreign_key => 'source_revision_id' end
class Environment < ActiveRecord::Base belongs_to :layout belongs_to :life_cycle has_many :revisions has_many :titles, :through => :environment_titles end
I've tried many different variations, singular/plural, etc. BTW, the 'source_revision' one works fine (I tried specifying everything to the environment belongs_to but it didn't matter)
Here's my tables, any clues? I'm REALLY stuck...
desc revisions;
Name Null? Type ----------------------------------------- --------