When the notifications button is clicked it sends a get request to controller which is supposed to update the Activity.viewed to true from false. This way my js knows not to populate it back into the notifications count. So:
I have an ajax GET request
// click EVENT TRIGGERS
$('#bell-notices').click(function(){
var $bell = $(this);
$bell.find('.notifications-count').hide('0');
$bell.parent().find('.dropdown-toggle').dropdown();
$.get('/activities/mark_activity_viewed', function( data ) {
});
});
being sent to rails controller
def mark_as_viewed
@mark = Activity.find_by(params[:id])
@mark.viewed = true
@mark.save!
end
everything is in place properly it seems, yet I can't get the database to update.
Console for Activity.last
<Activity id: 190, user_id: 68, action: "created", targetable_id: 157, targetable_type: "Status", created_at: "2015-03-04 21:17:57", updated_at: "2015-03-04 21:17:57", commentable_id: nil, reference_id: nil, viewed: false>
user_id in this case is the user who created the activity, not the user that's receiving it.
$.get. Also no idea whereidwould come from to be able to send it. Show some html source code