E
E
eldar_web2016-01-08 16:15:38
Ruby on Rails
eldar_web, 2016-01-08 16:15:38

How can I select data from a database based on an arithmetic condition in Ruby on Rails?

For example, there is a Table1 table, and there are price and price_paid fields.
I want to select items where at price - price_paid > 0.
How can I do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2016-01-08
@eldar_web

Very simple:
YouModel.where("price - price_paid > 0")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question