Ive got a table which consists of two fields called follower_id and followed_id. I need to create a query which creates an array of from each row and puts that in an overall array so that the end structure looks like:
"edges": [
["1", "2"],
["1", "3"],
["3", "4"],
["3", "5"]
]
so far I have
def self.including_relationships
result={}
result["edges"] Relationship.all.each do |relationship|
result[""]= Relationship.select(:follower_id.to_s,:follower_id.to_s)
#the code here is called once for each user
# user is accessible by 'user' variable
end
result
end
but this produces:
edges: [
"[4, 3, 3, 4]",
"[3, 4, 3, 4]"
]
has_many :throughconstructs? See the rails guide for associations.