diff --git a/app/controllers/links_controller.rb b/app/controllers/links_controller.rb index c0b2a8b..fb67438 100644 --- a/app/controllers/links_controller.rb +++ b/app/controllers/links_controller.rb @@ -15,7 +15,7 @@ class LinksController < ApplicationController end def show - @link = Link.goto(params[:id]) + @link = Link.get_and_count(params[:id]) #update link count diff --git a/app/models/link.rb b/app/models/link.rb index d5ad7e9..c60e2a6 100644 --- a/app/models/link.rb +++ b/app/models/link.rb @@ -7,9 +7,10 @@ class Link < ActiveRecord::Base Link.where("DATE(release) <= DATE(?)", Time.now).order("release DESC") end - def self.goto(id = nil) + def self.get_and_count(id = nil) return false if nil + link = nil Link.transaction do link = Link.find(id) link.visits += 1