I have a list of 'destinations'. There is a LIKE button next to each destination as well as a like count. I was able to get this 'liking system' working locally. however, once deployed to heroku, the 'like count' is displayed as 'undefined' and then whenever you click the like button, the like count turns to 'NaN'. How can I get the liking system to work on my heroku app??
In my javscript console, I notice there is no like_count column like there should be. But my migration and schema file say otherwise...
Schmea.rb file:
create_table "destinations", force: :cascade do |t|
t.string "name"
t.string "address"
t.time "start_time"
t.date "date"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "trip_id"
t.integer "day_id"
t.integer "like_count"
t.integer "duration"
t.time "end_time"
end
I implemented the liking system in a javscript file:
var like_cell = row.insertCell(2);
like_cell.innerHTML = '<input type="button" id="like-btn" type="button" value = "Like"</input>';
var like_count_cell = row.insertCell(3);
like_count_cell.innerHTML = dest.like_count;
$('#like-btn').click(function() {
dest.like_count += 1;
like_count_cell.innerHTML=dest.like_count;
console.log('hi');
console.log(dest.like_count);
console.log(dest);
sortTable();
});
function sortTable(){
var tbl = document.getElementById("destTable").tBodies[0];
var store = [];
for(var i=1, len=tbl.rows.length; i<len; i++){
var row = tbl.rows[i];
store.push([table.rows[i].cells[3].innerHTML, row]);
}
store.sort(function(x,y){
return y[0] - x[0];
});
for(var j=0, len=store.length; i<len; i++){
tbl.appendChild(store[j][1]);
}
table = tbl;
store = null;
}