For some reason, the order method is not working in my code. If I do in a model:
def apple
@tasks_array = self.tasks.to_a
end
With the code above, an array is returned. But if I do:
def apple
@tasks_array = self.tasks.order('order_number').to_a
end
then
[]
is returned. Here is the array that should be returned and that gets returned with the first block of code I wrote:
[#<Task id: 145, title: "task 1", content: "", created_at: "2013-12-18 18:44:31",
updated_at: "2013-12-18 20:21:11", schedule_id: 79, amount: nil,
time_frame: "2013-12-19 15:00:00", state: "complete", denied: 3,
order_number: 0>, #<Task id: 146, title: "Task 2", content: "",
created_at: "2013-12-18 18:44:31", updated_at: "2013-12-18 20:24:06",
schedule_id: 79, amount: nil, time_frame: "2013-12-27 10:00:00",
state: "complete", denied: 1, order_number: 1>]
I have also tried taking out .to_a but it still does not work.