I have an object Guess and did
y guess = Guess.find_by_id(5)
and got this
id: "5"
firstanswer_chambersapp: f
firstanswer_interview: f
firstanswer_letter: f
firstanswer_drafting: f
firstanswer_barrister: f
firstanswer_solicitor: t
secondanswer_chambersapp: "6"
secondanswer_interview: "2"
secondanswer_letter: "3"
secondanswer_drafting: "5"
secondanswer_barrister: "4"
secondanswer_solicitor: "1"
What I want to do is get all the secondanswers_ and sort them by the integer value (ASC). Is there a way I can do that in ruby/rails?
I'm expecting it to involve
guess.each do |e|
end
but I'm lost as to the code in the middle :(
Any hints would be helpful. I could also obviously retrieve all results at once
y guess = Guess.all
If that makes them any easier to sort
I'm also wondering if I set the database up the wrong way to make it practical to retrieve the values..