Hoping someone might be able to throw me a few clues on this one.
I’m working with lists of names a User (current_user) manages lists of
names, some male some female (scoped on m or f in gender), it’s all set
up such that I can do things like this - all working out fine.
(returns a list of the current users male names, pretty standard stuff I
a Name has the following attributes
What I’d like to do next is a little scary for me but I’m sure possible,
it is list comparison.
Basically for any given name, I’d like a method that returns other names
from other users lists where they have that given name in the list
(phew what a mouthful, not sure if that’s explained correctly, I think
For example, I’d like to do this.
given user Bob has a list of male names like this
and user Sally has a list of male names like this
name = User.find_by_username(‘Bob’).names.first
what I’d like is a method like this
which would return nil as no other users have ‘robert’
name = User.find_by_username(‘Bob’).names.last
This should return keith and paul from Sally’s list.
sorry for the verbose message.
Confused if I should start with a class or instance method for starters!