post visit count.

I would say first off add a view_count field to your migration for the post model and then add an increment_view_count method to the post model.

You can then call that method from within the view method of your post controller.

Something like that anyway.


Try this

def show    @post = Post.find(params[:id])    @post.increment_count end

def increment_count unless count.nil?    count += 1 else    count = 1 end end

try this:

def increment_count unless self.count.nil?   self.count += 1 else   self.count = 1 end end