get data with relation from 2 -3 tables

i have table user,user_device and device,

so user and and device id is mapped with user_device table

user table

id username password parent

1 admin admin null

2 user1 user1 1

3 user2 user2 2

device table

id title

1 abc-1234


id user_id device_id

1 2 1

now i want like admin is login and get all child user and get their device from user device table and get their device name from device table

how to do that

Check relations in ActiveRecord: