I have a method in my application helper that is meant to deactivate a task in my database.
Application helper:
def link_to_destroy_task(task_id)
Task.find(task_id).deactivate
end
Model:
def self.deactivate()
update_attribute(:active, false)
end
View:
<ol id="tasks">
<% @Tasks.each do |task| %>
<%content_tag_for :li, task do %>
<span class ="handle"> [drag] </span>
<%= link_to task.name, :controller => "com_tasks", :action => "edit", :id => task.id %>
<%= link_to_function '[Delete]', link_to_destroy_task(task.id) %>
<% end %>
<% end %>
</ol>
For some reason when the page loads it is deleting everything from the list. Not just switching active to false. It is completely wiping it from the database.
I am using fixtures, so I reload all the test data, and I can refresh once to see the data again, but the next time I reload it is gone.
I have changed the name of the method to 'deactivate' because I think destroy is already taken, but the method is still being run without being clicked. It isn't deleting anymore, but it is deactivating everything.