Reputation: 324
I'm using Rails 3.0.3
I have this code in my Partial:
<% tasks = Task.find_all_by_user_id_and_done_date(@current_user.id,nil).count %>
And with javascript i render the Partial (with shows the number of tasks to do) every 10 secounds.
I want to set the number of the tasks without reloading the page. The Javascript code is executing right (I tested it with alert()), but the Task Number isnt right . I think the Problem is that Rails dont send a sql-query to the database, because of sql-query Chaching. How can i deactivate this for this one query?
Upvotes: 0
Views: 268
Reputation: 3236
It's not about sql-query caching. Once the page is rendered, your partial becomes just static html that doesn't change.
What you need to do is send an Ajax request to the server and get the fresh count, as JSON object for example, and update the page with this value.
Upvotes: 3