TypeError on sef-referential association

I have a self-referential association using the following two models:

class User < ActiveRecord::Base
has_many :incoming_friendships, :foreign_key
=> :user1_id, :class_name => :friendship
has_many :outgoing_friendships, :foreign_key
=> :user2_id, :class_name => :friendship
has_many :incoming_friends, :through => :outgoing_friendships
has_many :outgoing_friends, :through => :incoming_friendships
#…
end

class Friendship < ActiveRecord::Base
belongs_to :user1, :class_name => :user, :foreign_key => :user1_id
belongs_to :user2, :class_name => :user, :foreign_key => :user2_id
end

In theory (according to josh;
has_many :through - Self-referential has_many :through associations)
this should work fine. However, I’m having some trouble…

When using the console, I try the command
“User.find(1).incoming_friends”. This results in a TypeError;

User.find(1).incoming_friends
TypeError: can’t convert Symbol into String
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/
lib/active_record/base.rb:1087:in type_name_with_module' from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/ lib/active_record/base.rb:1356:in compute_type’
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/
lib/active_record/reflection.rb:125:in send' from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/ lib/active_record/reflection.rb:125:in klass’
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/
lib/active_record/reflection.rb:177:in source_reflection' from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/ lib/active_record/reflection.rb:177:in collect’
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/
lib/active_record/reflection.rb:177:in source_reflection' from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/ lib/active_record/reflection.rb:186:in check_validity!’
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/
lib/active_record/associations/has_many_through_association.rb:6:in
initialize' from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/ lib/active_record/associations.rb:934:in new’
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/
lib/active_record/associations.rb:934:in `incoming_friends’
from (irb):1

If anyone has a clue what I might be doing wrong, I’d greatly
appreciate some help!

I figured it out with help from somewhere else…for those who might
be interested the solution was to name classnames and column names
with strings, not symbols. It puzzles me why, but at least that solved
my problem. So the two finished models looks like this:

class User < ActiveRecord::Base
#Friendship relations
has_many :incoming_friendships, :class_name =>
“Friendship”, :foreign_key => “user1_id”
has_many :outgoing_friendships, :class_name =>
“Friendship”, :foreign_key => “user2_id”
has_many :incoming_friends, :through
=> :outgoing_friendships, :source => :user1
has_many :outgoing_friends, :through
=> :incoming_friendships, :source => :user2

def friends
incoming_friends.find(:all, :conditions => :confirmed != nil) +
outgoing_friends.find(:all, :conditions => :confirmed != nil)
end
end

class Friendship < ActiveRecord::Base
belongs_to :user1, :class_name => “User”, :foreign_key => “user1_id”
belongs_to :user2, :class_name => “User”, :foreign_key => “user2_id”
end