Try something like this:
@redeemables = @business.redeemables.sort_by {|r| "#{r.expiry_date.blank?} #{r.desc}" }
Basically, this is sorting by concatenated string: whether the expiration date ( true/ false) and description are empty . (e.g. false item_description).
If you want to change the nil sort order expiry_dates, you can do the following:
@redeemables = @business.redeemables.sort_by {|r| "#{r.expiry_date.present?} #{r.desc}" }
source
share