jeudi 18 février 2016

How to write active record query to details by using and

i have two tables

1)Properties :fields are id, name, propert_type,category_id

2)Admins : fields id, name,mobile,category_id

i want to write an active record to list all properties , where category_id in properties table and category_id in Admins table are equal

i am listing this property list by logging as admin.

i wrote active record like this , but i got error, can anyone please suggest me a solution for this

@properties= Property.where('properties.category_id=?','admins.category_id=?').and('admins.id=?',current_user.specific.id)

enter image description here

Aucun commentaire:

Enregistrer un commentaire