Ruby on rails Problem

12 views
Skip to first unread message

ezyb...@gmail.com

unread,
Oct 15, 2015, 9:43:58 AM10/15/15
to Ruby on Rails: Talk
can some one tell me how to write this in ruby on rails active records objects form id 


Payment.joins(:tenants).where(:payments {:name 'sample'})


SELECT p.*, `tenants`.*, IF (IFNULL(p.`amount`,'0') = 0, 'Pay Now', 'Paid') AS amount2 FROM (
SELECT
`payments`.`amount`
, `payments`.`tenant_id`
FROM
`payments` WHERE payments.`created_at` BETWEEN '#{Time.now.beginning_of_month}' and '#{Time.now.end_of_month}' ) AS p
RIGHT JOIN `tenants`
ON (p.`tenant_id` = `tenants`.`id`);
Reply all
Reply to author
Forward
0 new messages