So I am retrieving a dataset of blog posts from DatoCMS using the dato gem and the paginate gem. This is being done in the config.rb to generate pages of blog posts. I want to sort them by date_published obviously but I also want to put the ‘sticky’ posts at the top (note to self, I want to swap the order that I call the sort fields and sort by issticky first!! lol). I thought I had figured it out (the syntax was killing me) , however when i used a boolean to sort by (namely:issticky) I find that ruby doesn’t support ordering by boolean field!. I found the work around whereby you change the boolean values into a 0 or 1 and then ruby will sort by integers but I am getting following error.
`block in evaluate_configuration!’: wrong argument type Integer (expected Proc) (TypeError)
Can anyone help or suggest another way to get same result. Not sure if I am nearly there, just an issue with syntax or if i am wasting time with this approach
dato.tap do |dato|
paginate dato.blogs.sort_by(&:date_published && :issticky ? 0 : 1), "/blog", "/templates/blogs.html", per_page: 10
end
Can anyone help
@tomrutgers can you weigh in on this at all, you seem to know your way around the beast I call ruby!! lol