-
-
Save universal/e7adcb465a70338b3906 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- ERR | |
uninitialized constant User::Aimed | |
--- Facing cols | |
id, aimer_id, aimed_id, aimed_kind (will be deprecated), aimed_type, created_at, updated_at |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- Facing.rb | |
class Facing < ActiveRecord::Base | |
#Relation model dealing with users pointing to users | |
#belongs_to :aimer, class_name: "User" | |
belongs_to :aimer, :polymorphic => true | |
#belongs_to :aimed, class_name: "User" | |
belongs_to :aimed, :polymorphic => true | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
#People the user is facing (objects: records & user/clan objects) | |
has_many :active_facings, as: :aimer, class_name: "Facing", foreign_key: "aimer_id", dependent: :destroy | |
has_many :aimeds, through: :active_facings, source_type: "Aimed" | |
#People who is facing the user (objects: records & user/clan objects) | |
#old: has_many :passive_facings, class_name: "Facing", foreign_key: "aimed_id", dependent: :destroy | |
has_many :passive_facings, as: :aimed, class_name: "Facing", foreign_key: "aimed_id", dependent: :destroy | |
has_many :aimings, through: :passive_facings, source_type: "Aimed" | |
def aims_to?(other) | |
# if other.class.name == 'User' | |
aimeds.include?(other) <----------------------------- IT BREAKS HERE!! | |
# elsif other.class.name == 'Clan' | |
# active_facings | |
# end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment