All threads / How can I convert this code to raw SQL and use in rails?
Ask A Question

Notifications

You’re not receiving notifications from this thread.

How can I convert this code to raw SQL and use in rails?

Priya Sharma asked in Rails

How can I convert this code to raw sql and use in rails? Because When I deploy this code in Heroku, there is a request timeout error. I think this will be faster if I use raw sql.

@payments = PaymentDetail.joins(:project).order('payment_details.created_at desc')
@payment_errors = PaymentError.joins(:project).order('payment_errors.created_at desc')

@all_payments = (@payments + @payment_errors)

@all_payments = PaymentDetail.joins(:project).order('payment_details.created_at desc')
  .union(PaymentError.joins(:project).order('payment_errors.created_at desc'))
  .order('created_at desc')
Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 69,840+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2023 GoRails, LLC. All rights reserved.