Rails counter cache not updating
So that is all we're going to need on the user model, this will go ahead and create our migrations for that, and once we're done creating all of our model migrations, we'll go edit those and add in those defaults.
So here we go, we will have our model for column that is an integer, and it will point to the user.
So this one also needs So if we open up Mac Vim now, and go into our database/migrations, we can add a default of zero, and I'm going to also say null is false, so that we always have some sort of integer for these columns.
so in the database, it actually took this, coalesced the count of that column, and said: Well if it's null, let's set it to zero, and then let's also add one to it.
And all of this is done on a database level so there's no ruby involved for incrementing or decrementing that column, which is really neat.
So that is all we need on forum posts: app/models/forum_because we created that association as well.
So we have those, the user to a forum thread, and the user to a forum post, and we also have the user thread to the forum post.
So we're going to create a new Rails app, and let's just call it , we can then generate our mode for User, they'll probably need a name or email whatever, you know, you might create this with Devise or something, or you might just roll this from scratch, we're going to not do anything other than a blank model with name, and we'll also add as an integer.