vendredi 29 décembre 2017

Sorting Records on a Custom calculated value at the runtime- rails

I have Two models Product, Price

Product 
 has_many :prices

Price
 belongs_to :product

we have price_type and price_date attributes in the Price Model. price_type can be default, weekend, specific_date for a particular Product.

Product can have single price on a day like either it is weekend, or a specific_date otherwise default.

price_date will be matter when price_type will be specific_date

Now The problem is,

Date.today is passing in the parameters

I want to get all the products in the sorted by price on that date which is passing.

I'm trying to find the solution since a long time!

Please Help Me!

Thanks

Aucun commentaire:

Enregistrer un commentaire