I have a sql like this:
SELECT TOP 1 field_name * FROM table_name
and I want to covert it into activerecord in rails.
That code doesn't do the job?
YourModel.select(:field_name).first
or
YourModel.select(:field_name).order('id desc').first
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