Find monogo object using mongoid

Hi,
I am using mongoid with rails 3 for my application.
My problem is I have a task list where each task has checkbox to mark
whether has it completed or not.
For that I have written code like this

<%=check_box_tag ‘task_is_complete’, nil, nil,
:onclick=>“complete(’#{task.id}’);” %><%=task.name%>

On click I am doing ajax call to my controller

def complete
task=Task.where(params[:task_id])
puts task.inspect
end

But I am not able to fetch the task.
My mongo db record is
“{ “_id” : ObjectId(“4d8818d1e138230a5f000007”), “name” : “Scraping”,
“project_id” : ObjectId(“4d881886e138230a5f000003”), “due_date” : “Thu
Mar 31 2011 05:30:00 GMT+0530 (IST)”, “note” : “Scrape two vendors” }”

Also, the value passed to controller i.e params[:task_id] has value
“4d8818d1e138230a5f000007”.

Can anyone tell Am I missing anything?

Thanks,
MIke

Hej Mike,

the where-method takes a Hash to grab your records, so you either change
your call to “Task.find(params[:id])” or Task.where(:_id =>
params[:id]).first

Best,
Sebastian