I have a task model and in the controller there is this code that sets
the date a task was completed on if params[:completed] comes back as
true and sets the completed_by field to nil (ie incomplete) if params
[:completed] comes back as false:
Users can edit the task and this code is in the edit view - allowing
the user to tick the box to mark a task as complete or untick it to
change the task’s status back to incomplete:
<%= check_box_tag :completed, “1”, @task.completed_on %>
This all works fine. However, if I try to use AJAX to access the
update controller directly with the following urls:
/tasks/3?completed=true, _method = PUT
/tasks/3?completed=false, _method = PUT
The first one works, but the second doesn’t reset the completed_by
field back to nil.
Does anybody know why this isn’t working? I’ve a feeling it might be
because ruby is seeing ‘false’ as a string and therefore ‘true’.