activerecord - How to write using where and and conditions on active record rails -


how write query using , and conditions on active record rails

select c.name fromcategoriesas c join categories_coaches cc on cc.category_id=c.id cc.coach_id=16 , c.parent_id=1

this should it:

category.joins(:categories_coaches)     .where('categories_coaches.id = ? , categories.parent_id = ?', 16, 1)     .select('categories.name') 

Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

html - Outlook 2010 Anchor (url/address/link) -