Using the following code in my controller, I am able to retrieve all rows from my table, but it won't sort by the column last_name
. Any suggestions?
@pi_names = PiName.all(:order => 'pi_names.last_name DESC')
Try
@pi_names = PiName.order('pi_names.last_name DESC').all
Alternative syntax allowing any errors to potentially be caught prior to runtime:
@pi_names = PiName.order(last_name: :desc)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With