Let me explain my problem:
I have 2 models:
class User < AR::Base
has_many :contacts
end
class Contact < AR::Base
belongs_to :user
belongs_to :user_contact_id, :class_name => "User", :foreign_key => "user_contact_id" # The "contact" is an ID from the table user.
def self.is_contact?(user_contact_id)
# CHECK IF THE RECORDS EXIST VIA DB OR CACHE OR WHATEVER #
end
end
Having a instance of User as @user, you can check is_contact? like this:
@user.contacts.is_contact?(a_user_id)
This works perfectly, my problem is that I want to access to attributes of @user, inside the is_contact? method in Contact.
Is this possible?
Thank to all you guys.