Ruby on Rails Thursday, October 15, 2015

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`);

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/abf363cb-45f1-4f78-b63e-d7516efb3380%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment