i think i used the right terminology for what i need, i currently have a database call in my home_controller that is returning a call to my database with all the entries in that table specified, Freelancer.
There is an attribute on these records that has either a true or false value, which is "featured".
I need a way to call a sort method, or some other way, on that object with the true being first and then the false being afterwards, i tried using this code
def index
@freelancers = Freelancer.all
p 'below im outputting featured freelancer i hope'
@freelancers.sort_by { |row| [row.featured ? 0 : 1, row.id]}
p @freelancers
end
But unfortunately this did not work, can anyone advise me on a way to get this to work? Id rather have the sorted object returned as is, rather then assigning it to a new one. Just for future features of adding pagy and a filter by cost.
>Solution :
Use order method
def index
@freelancers = Freelancer.order(featured: :desc)
end