I am having a problem with doing a :through that goes back to the same table.
The following are my two classes:
class User < ActiveRecord::Base
has_many :spanked, :through => :spanks, :source => :spanked_user
has_many :was_spanked_by, :through => :spanks, :source => :user
class Spank < ActiveRecord::Base
belongs_to :spanker, :class_name => "User", :foreign_key => "user_id"
belongs_to :spankee, :class_name => "User", :foreign_key => "spanked_user_id"
id | user_id | spanked_user_id | created_at | updated_at
I want to be able to make statemets like:
john = User.find_by_nickname("john")
Can I do this without using a :finder_sql?
The above does not work... but the following does:
spank = Spank.find(1)
Help... help... I get the following error: