With the following code I'm ordering the products whichever one was created or update last:
@products = Product.where(:id=> @account.id).order('greatest(created_at, updated_at) desc').page(params[:page]).per(12)
It works just fine, but since I'm getting the following message in the console I was wondering if there is a better way to implement the above??
DEPRECATION WARNING: Dangerous query method (method whose arguments
are used as raw SQL) called with non-attribute argument(s):
"greatest(created_at, updated_at) desc". Non-attribute arguments will
be disallowed in Rails 6.0. This method should not be called with
user-provided values, such as request parameters or model attributes.
Known-safe values can be passed by wrapping them in Arel.sql().